Handle window on load event - Javascript DOM

Javascript examples for DOM:Element addEventListener

Description

Handle window on load event

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <button type="button" id="testButton">Test</button> 
      <script type="text/javascript">
function testFunction() {/* w w w. j  av  a2 s  .c  o m*/
    console.log("It works!");
}
window.addEventListener('load', function () {
    document.getElementById('testButton').addEventListener('click', testFunction, false);
}, false);

      </script>  
   </body>
</html>

Related Tutorials