Skip to content

Instantly share code, notes, and snippets.

@colinramsay
Created September 6, 2009 19:49
Show Gist options
  • Save colinramsay/181944 to your computer and use it in GitHub Desktop.
Save colinramsay/181944 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>untitled</title>
<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#start').bind('click', function(e) {
e.preventDefault();
// clear the contents of the current page
document.body.innerHTML = '';
// create a new iframe the size of the browser window
var frame = document.createElement('iframe');
frame.id = 'testFrame';
frame.width = $().width();
frame.height = $().height();
frame.border = 0;
frame.frameBorder = 'no';
document.body.appendChild(frame);
// set the source of the new iframe
$('iframe#testFrame').attr('src', 'page2.html');
// load the frame & specify a callback for load complete
$('iframe#testFrame').load(function()
// get the frame's content document and bind a click event to the links
var fd = $($('#testFrame').get(0).contentDocument);
fd.contents().find('a').bind('click', function() {
console.debug(this);
});
});
});
});
</script>
</head>
<body>
<a href="#" id="start">click here</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment