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.
Comments
Post a Comment