Skip to content

Instantly share code, notes, and snippets.

@matthewmueller
Created August 22, 2012 22:56
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 matthewmueller/3430398 to your computer and use it in GitHub Desktop.
Save matthewmueller/3430398 to your computer and use it in GitHub Desktop.
Clean window
/**
* Written by Jonathan Bolster
* Blog Post: http://bolsterweb.com/2011/10/how-clean-is-your-window-object/
*/
(function(window){
var keys = {},
cleanWindow,
iframe = document.createElement("iframe");
iframe.style.display ="none";
iframe = document.body.appendChild(iframe);
cleanWindow = iframe.contentWindow;
document.body.removeChild(iframe);
for(var keyName in window){
keys[keyName] = window[keyName];
}
for(var keyName in cleanWindow) {
delete keys[keyName]
}
return keys;
}(window))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment