Skip to content

Instantly share code, notes, and snippets.

@jljohnstone
Last active August 29, 2015 14:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jljohnstone/1676b3870a0049d0913c to your computer and use it in GitHub Desktop.
Save jljohnstone/1676b3870a0049d0913c to your computer and use it in GitHub Desktop.
display a page inside of a div in another page
<!DOCTYPE html>
<html>
<head>
<title>There's a page in my div</title>
<style type="text/css">
.the-div {
border: 1px solid #555;
}
</style>
</head>
<body>
<p><a href="page.html" class="open-in-div">click the link</a> and a page will appear in the div below</p>
<div class="the-div"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
$('.open-in-div').click(function(e) {
e.preventDefault();
$('.the-div').load($(this).attr('href'));
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>I'm that page</title>
</head>
<body>
<p>I'm a page that is displayed in a div</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment