Skip to content

Instantly share code, notes, and snippets.

@jakobo
Created June 15, 2011 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakobo/1026304 to your computer and use it in GitHub Desktop.
Save jakobo/1026304 to your computer and use it in GitHub Desktop.
BLOG: adoptNode()
try {
document.adoptNode(window.opener.$("#my-iframe"))
}
catch(exc) {
// performance hit. Either importNode, or load the frame contents with appendChild()
document.importNode(window.opener.$("#my-iframe"))
}
<div id="#placeholder"></div>
<!-- ...last node in the page... -->
<iframe id="theFrame" src="http://www.example.com" style="left: -12345px; top: 0; position: absolute;"></iframe>
</body>
(function() {
var div = document.getElementById("placeholder");
var iframe = document.getElementById("theFrame");
window.setInterval(function putFrameOntoPlaceholder() {
// 1) measure the size of the iframe, change size of div
div.width = iframe.offsetWidth + "px";
div.height = iframe.offsetHeight + "px";
// 2) get the div's position on the page, position iframe
iframe.left = div.offsetLeft + "px";
iframe.top = div.offsetHeight + "px";
}, 100);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment