What is the right way to add an onload function?
-
It seems my onload is replaced by wordpres’s.
I’m adding javascript in the header (not a link) from a plugin.
I tried the following no success:
function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(function() { /* my code here */ });
Is there an official way to do it?
- The topic ‘What is the right way to add an onload function?’ is closed to new replies.