Jump to content

Mouseover rollover mouseover rollback


METOOTECH

Recommended Posts

Hi, me again..... This is not really a rollover but an image switch... I was wondering if after you switch images with a simple inline mouseover if you could switch back to the first image with an inline 2nd mouseover. Actually I would like it to switch back and forth between 2 images with each mouseover using just inline javascript. Now, I'm not talking about switch back with a mouseout, just mouseovers. Is this possible? Any help is appricated very much..... :) "thinking outside the box" METOOTECH :) THE CODE:<img id="ads2" src="http://www.knifeknives.com/ba/backs-logos/SUNSPOT1B.jpg" height="130" width="130" border="0" onmouseover="this.src='http://www.knifeknives.com/ba/backs-logos/DARKSTAR2.jpg'">OR...<aonmouseover="ads1.src='http://www.knifeknives.com/ba/backs-logos/DARKSTAR2.jpg'"><img id="ads1" src="http://www.knifeknives.com/ba/backs-logos/SUNSPOT1B.jpg" height="130" width="130" border="0" /></a>p.s. This is the code for just the first switch, couldn't figure out how to switch back, let along how to switch back and forth...Believe it or not, I do figure out 95% of my problems with code myself! :)

Link to comment
Share on other sites

I don't think it will work with 2 mouseovers. I would do something like this:

<script>firsttime = true;function switchImage(obj){if (firsttime){firsttime = false;obj.src = 'firstimage.jpg';} elseobj.src = 'secondimage.jpg';}</script><img src="image.jpg" onmouseover="switchImage(this);">

Link to comment
Share on other sites

It works great, through 1 run through, is there any way to get it to switch back and forth between the 2 images each time it's moused over?? :) thanks for you help!...... METOOTECH

The condition in the script always remained false, you need to set it back to true in the else statement, should now work ok. :) <head><script>firsttime = true;function switchImage(obj){if (firsttime){obj.src = 'http://w3schools.invisionzone.com/style_images/w3sbanner.gif';firsttime = false;} else {obj.src = 'http://www.w3schools.com/images/logo_new2.jpg';firsttime = true;}}</script></head><body><img src="http://www.w3schools.com/images/logo_new2.jpg" onmouseover="switchImage(this);"></body>
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...