I have a script which may be loaded at any stage of the life cycle of a web page. When the script is loaded it must run an initialize() method.
I want this function to be run on the "onload" event, but I cannot be certain that the page has not already loaded, i.e. that the "onload" has not been fired already.
Ideally my script would look like this:
var _initialize = function() { ...};
if(window.LOADED)
_initialize();
else if (window.addEventListener)
window.addEventListener('load', _initialize, false);
else if (window.attachEvent)
window.attachEvent('onload', _initialize);
Is there any such window.LOADED or document.LOADED variable or something similar?
Thanks in advance, Shane