Last active
December 22, 2015 01:30
-
-
Save tommyh/db777fddbdc5040b8dc3 to your computer and use it in GitHub Desktop.
onGlobalDefined
This file contains 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
var onGlobalDefined = function(func, varName){ | |
if(typeof window[varName] !== "undefined"){ | |
console.log("running"); | |
func(); | |
} else { | |
console.log("waiting"); | |
setTimeout(function(){ | |
onGlobalDefined(func, varName); | |
}, 10); | |
} | |
} | |
onGlobalDefined(function(){ | |
alert("window.BKTAG" is ready"); | |
}, "BKTAG"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
onPropertyDefined(function(){}, function(){ return window.BKTAG });
onPropertyDefined(function(){}, "BKTAG");