/ Published in: JavaScript
Window.onload chaining using Namespaces.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* Run code inside a new namespace. This will allow the use of * the same variable 'previous_onload', across multiple namespaces. * * Use the exact same code multiple times, and your functions * will be executed in the order in which they were stacked. */ (function() { // Backup previous onload method. var previous_onload = window.onload; window.onload = function() { try { previous_onload(); } catch(e) { } // Execute. Ignore if error. // Your code goes here console.log("Running Code..."); } })();
URL: http://paste.pocoo.org/show/378207/