
Untitled
By: a guest on
May 9th, 2012 | syntax:
None | size: 0.95 KB | hits: 15 | expires: Never
Javascript - Detect if any javascript function is running
<script async defer src="yourfile.js"></script>
(function() {
if (window.addEventListener) {
window.addEventListener("load", loadHandler, false);
}
else if (window.attachEvent) {
window.attachEvent("onload", loadHandler);
}
else {
window.onload = loadHandler; // Or you may want to leave this off and just not support REALLY old browsers
}
function loadHandler() {
setTimeout(doMyStuff, 0);
}
function doMyStuff() {
// Your stuff here. All images in the original markup are guaranteed
// to have been loaded (or failed) by the `load` event, and you know
// that other handlers for the `load` event have now been fired since
// we yielded back from our `load` handler
}
})();
window.addEventListener("load", function() {
setTimeout(function() {
// put your code here
}, 1);
}, false);