Skip to content

Instantly share code, notes, and snippets.

@MiguelDebruyne
Last active November 22, 2016 11:27
Show Gist options
  • Save MiguelDebruyne/12a1628bd4cb7dc86aa35b84ae65e788 to your computer and use it in GitHub Desktop.
Save MiguelDebruyne/12a1628bd4cb7dc86aa35b84ae65e788 to your computer and use it in GitHub Desktop.
JS: Get all user defined window properties
(function () {
// create an iframe and append to body to load a clean window object
var iframe = document.createElement('iframe');
iframe.style.display = 'none';
document.body.appendChild(iframe);
// get the current list of properties on window
var currentWindow = Object.getOwnPropertyNames(window);
// filter the list against the properties that exist in the clean window
var results = currentWindow.filter(function(prop) {
return !iframe.contentWindow.hasOwnProperty(prop);
});
// log an array of properties that are different
console.log('Total user objects on window: ', results.length);
console.log(results);
document.body.removeChild(iframe);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment