Javascript examples for DOM:Element addEventListener
Handle window on load event
<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>