Javascript examples for DOM:Event
Create JavaScript Event with attached data
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w w w . j a v a 2 s.c o m var evObj = document.createEvent('HTMLEvents'); document.body.addEventListener('test', function(e){ document.body.innerHTML = (e === evObj); },true); evObj.initEvent('test', true, true); document.body.dispatchEvent(evObj); } </script> </head> <body> </body> </html>