Hi,
I am trying to use img.onmouseover inside window.onload. For examples, I want some images on the webpage to do something when visitor moves their mouse over it. But I don't want to put onmouseover inside the tag in html and I decided to do it in window.onload for design reason, and I do img.onmouseover=myfunction() in window.onload. I get the img from document.getElementsByTagName('img'), then get the correct img by traversing the tree.
I move my mouse to the image, it does what I want. But the problem is that once I move my mouse out of the image and move back in it, it doesn't do it anymore.
I tried to do img.onmouseout= function(){img.onmouseover=myfunction();}; but it still doesn't do it. Do you know how to fix it?
Many thanks.
I am trying to use img.onmouseover inside window.onload. For examples, I want some images on the webpage to do something when visitor moves their mouse over it. But I don't want to put onmouseover inside the tag in html and I decided to do it in window.onload for design reason, and I do img.onmouseover=myfunction() in window.onload. I get the img from document.getElementsByTagName('img'), then get the correct img by traversing the tree.
I move my mouse to the image, it does what I want. But the problem is that once I move my mouse out of the image and move back in it, it doesn't do it anymore.
I tried to do img.onmouseout= function(){img.onmouseover=myfunction();}; but it still doesn't do it. Do you know how to fix it?
Many thanks.
Comment