My simple solution is this one, anonymous function with multiple callbacks after document.body is not undefined.
(function(){if(document.body){for(var i=0;i<arguments.length;i++)arguments[i]();}else setTimeout(arguments.callee,1)})
(initLightbox, otherFunc, somethingElse, init);
Just 2 simple lines of code, but for some reason it shouldn't work correctly in some case.
Then, while my test page doesn't fail this method, at least with my browsers, I'd like to know when this way shouldn't work correctly or when this way should work (I always prefere to reduce JS size then if generic cases work correctly with this method to implement DOMContentLoaded I'll prefere this one).
Can anyone explain me what's up when this method fail ? Thank you.
No comments:
Post a Comment