Skip to content

Instantly share code, notes, and snippets.

@gcpantazis
Created October 23, 2012 17:56
Show Gist options
  • Save gcpantazis/3940352 to your computer and use it in GitHub Desktop.
Save gcpantazis/3940352 to your computer and use it in GitHub Desktop.
Creating and Destroying Iframes, Qunit Tests.
// Create an <iframe>, return the DOM object
// back to the caller once loaded.
var iframeLoad = function(pageURL, cb){
var iframe = document.createElement('iframe');
iframe.onload = function(event) {
// Return iframe to callback.
cb(event.target);
};
iframe.src = pageURL;
document.body.appendChild(iframe);
}
// Provide method for destroying a given <iframe> in teardowns.
var iframeUnload = function(iframe){
document.body.removeChild(iframe);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment