Skip to content

Instantly share code, notes, and snippets.

@akai
Created January 19, 2020 13:39
Show Gist options
  • Save akai/73f86a9fbe6653b1005be6f51df5d3be to your computer and use it in GitHub Desktop.
Save akai/73f86a9fbe6653b1005be6f51df5d3be to your computer and use it in GitHub Desktop.
获取自定义的全局变量
(function() {
var keys = [];
var iframe = document.createElement('iframe');
iframe.onload = function() {
var iframeKeys = Object.keys(iframe.contentWindow);
Object.keys(window).forEach(function(key) {
if (!(iframeKeys.includes(key))) {
keys.push(key);
}
});
console.log(keys);
};
iframe.src = 'about:blank';
document.body.appendChild(iframe);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment