Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 0.95 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Javascript - Detect if any javascript function is running
  2. <script async defer src="yourfile.js"></script>
  3.        
  4. (function() {
  5.     if (window.addEventListener) {
  6.         window.addEventListener("load", loadHandler, false);
  7.     }
  8.     else if (window.attachEvent) {
  9.         window.attachEvent("onload", loadHandler);
  10.     }
  11.     else {
  12.         window.onload = loadHandler; // Or you may want to leave this off and just not support REALLY old browsers
  13.     }
  14.  
  15.     function loadHandler() {
  16.         setTimeout(doMyStuff, 0);
  17.     }
  18.  
  19.     function doMyStuff() {
  20.         // Your stuff here. All images in the original markup are guaranteed
  21.         // to have been loaded (or failed) by the `load` event, and you know
  22.         // that other handlers for the `load` event have now been fired since
  23.         // we yielded back from our `load` handler
  24.     }
  25. })();
  26.        
  27. window.addEventListener("load", function() {
  28.     setTimeout(function() {
  29.         // put your code here
  30.     }, 1);
  31. }, false);