Reputation: 9
I was wondering how I can write document.onmousemove a different way? Here is the code:
document.onmousemove = something;
I can only seem to be able to run one function this way, how can I write it a different way?
Upvotes: 1
Views: 40
Reputation: 225074
Using addEventListener
:
document.addEventListener('mousemove', something, false);
For compatibility with IE8 and earlier, you can fall back on its attachEvent
(mind the prefix, and you’ll have to use window.event
instead of the argument):
document.attachEvent('onmousemove', something);
Upvotes: 2