Help - Search - Members - Calendar
Full Version: Image Mouse Rollover - reset
HTMLHelp Forums > Programming > Client-side Scripting
LucasD5
Hello everyone. I'm having one small problem with my mouse rollover images. (I'm self-taught and learning as I go.)

I got my Image mouseover script from this site:
http://www.webdevelopersnotes.com/tips/htm...e_rollover.php3

And I've gotten it to work. Here's the script they give:

SCRIPT----------------------------
<script type="text/javascript">
<!--

function roll(img_name, img_src)
{
document[img_name].src = img_src;
}

//-->
</script>
END SCRIPT-------------------------

...and the html code they give....

CODE-------------------------------
<a href="somewhere.html"
onmouseover="roll('sub_but', 'movedown.gif')"
onmouseout="roll('sub_but', 'movetup.gif')">

<img src="moveup.gif" width="143" height="39" border="0"
alt="Move your mouse over me" name="sub_but" />

</a>
END CODE---------------------------

This is working fine. The only problem I'm having is that when I select one of the rollover links, then use the back button on my browser to return to the home page, the rollover image isn't reset. In other words, the "onmouseover" image still shows. Can I put in a script that resets it to the initial image?

Here's the site: http://www.providence-bc.com/

Any help is appreciated!

LD


Darin McGrew
This isn't about Markup, so I moved it to the Client-side Scripting forum.
Nicholas_Roge
In the "<body>" tag, add onload="roll('sub_but', 'movetup.gif')".
Frederiek
Actually, why use javascript in the first place? The link simply changes from text and background color which easily could be achieved in CSS.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.