Posted By

ebukva on 11/17/06


Tagged

event onload


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

rnrleachryan
lux
skatan
wesbaker


addLoadEvent


 / Published in: JavaScript
 

  1. // addLoadEvent is Simon Willison's function that aloows for convenient
  2. // addition of multiple fuctions that are all supposed to be triggered
  3. // on window.onload event.
  4. // takes function name as the argument. e.g. addLoadEvent(doPopups);
  5.  
  6. function addLoadEvent(func) {
  7. var oldonload = window.onload;
  8. if (typeof window.onload != 'function') {
  9. window.onload = func;
  10. } else {
  11. window.onload = function() {
  12. oldonload();
  13. func();
  14. }
  15. }
  16. }

Report this snippet  

You need to login to post a comment.