Javascript examples for DOM:Element addEventListener
Handle window resize event
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/* w ww .jav a 2 s. c o m*/ function resizeHandler(e) { console.log(e.type + ' triggered.'); } window.addEventListener('resize', resizeHandler); var resizeEvent = new Event('resize'); window.dispatchEvent(resizeEvent); } </script> </head> <body> </body> </html>