Posted By

brianyang on 05/26/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jonkemp


Window Onload Cross Browser


 / Published in: JavaScript
 

  1. function init(){
  2. // quit if this function has already been called
  3. if (arguments.callee.done)
  4. return;
  5. // flag this function so we don't do the same thing twice
  6. arguments.callee.done = true;
  7.  
  8.  
  9. // code here
  10.  
  11. };
  12.  
  13. /* for Mozilla */
  14. if (document.addEventListener) {
  15. document.addEventListener("DOMContentLoaded", init, false);
  16. }
  17.  
  18. /* for Internet Explorer */
  19. /*@cc_on @*/
  20. /*@if (@_win32)
  21.  document.write("<script defer src=ie_onload.js><"+"/script>");
  22.  /*@end @*/
  23. /* for other browsers */
  24. window.onload = init;

Report this snippet  

You need to login to post a comment.