Cronthenoob Posted July 7, 2006 Share Posted July 7, 2006 I've got this bit of javascript I use to change an image to another image when the mouse goes over it. But i've got a special situation where I need the image to stay in the mouseover state while over certain links, then goes back to normal. The code I have now changes the image on mouseover, but doesnt change it back. I can make the image change to the original, however, when the mouse moves from the image, it changes immediatly. I only want it to go back to normal when the drop down menu dissappears.Heres the broken example <script type="text/javascript"> function init() { if (!document.getElementById) return var imgOriginSrc; var imgTemp = new Array(); var imgarr = document.getElementsByTagName('img'); for (var i = 0; i < imgarr.length; i++) { if (imgarr[i].getAttribute('hsrc')) { imgTemp[i] = new Image(); imgTemp[i].src = imgarr[i].getAttribute('hsrc'); imgarr[i].onmouseover = function() { imgOriginSrc = this.getAttribute('src'); this.setAttribute('src',this.getAttribute('hsrc')) } } } } onload=init;</script> Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 6, 2006 Share Posted August 6, 2006 If you want the image to switch back, you would use .onmouseout right?I don't see the images that have this function at that link.. ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now