javascript - Binding event to body tag -


i want bind event whole page - html or body tag. how can that?

this want achieve @ first:

document.addeventlistener('mousemove', function() { alert('a'); }); 

so doing whatever action mouse on website gives me alert.

but doesn't work, , console doesn't output anything. whole code:

<!doctype> <html>     <head>         <title>fdsjfkdsf</title>     </head>     <body>         fdjfkjdsf         <script type="text/javascript">             document.addeventlistener('mousemove', function() { alert('a'); });         </script>     </body> </html> 

i have tried:

document.getelementsbytagname('html')[0].addeventlistener('...'); window.addeventlistener('...'); 

but none works. how can solve this?

the first example provided works fine me in chrome.

check if getting errors in console.

example: https://jsbin.com/fepoguceyu/edit?html,output


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -