Created
January 19, 2020 13:39
-
-
Save akai/73f86a9fbe6653b1005be6f51df5d3be to your computer and use it in GitHub Desktop.
获取自定义的全局变量
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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