Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 6th, 2012  |  syntax: None  |  size: 0.56 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. document.ready like functionality in javascript?
  2. ...
  3.   <script>...</script>
  4.   </body>
  5. </html>
  6.        
  7. <body>
  8. <!--
  9. All your html tags here
  10. ....
  11. ....
  12. -->
  13.  
  14.  
  15.  
  16.     <script type="text/javascript">
  17.       //this should execute after the above tags and elements have rendered
  18.     </script>
  19. </body>
  20.        
  21. (function(w,evt,fn){
  22.         if (w.addEventListener){// W3C DOM
  23.             w.addEventListener(evt,fn,false);
  24.         }
  25.         else if (w.attachEvent) { // IE DOM
  26.             w.attachEvent("on"+evt, fn);
  27.         }
  28.  
  29.     })(window,'load',function(){
  30.        // your code here
  31.     });