PDA

View Full Version : anyone help w/ this javascript please?


dannykilla
09-02-2008, 08:25 PM
Hi,

I am trying to do a ImageRollover with this Javascript which you can see here:

http://www.thesitewizard.com/archive/rollovers.shtml

and here is my code (don't laugh, n00b here) and this is not working so can anyone point me in the right direction?

<a href="http://www.xxxxxxxxxx.co.uk"
onMouseover="buttondown('homebuttondown')"
onMouseout="buttonup('homebutton')">
<img src="http://www.xxxxxxxx.co.uk/images/homebutton.png" name="Home" border="0" />
</a>

<script language="JavaScript" type="text/javascript">
<!--
if (document.images) {
homebuttonup ="buttonup"('homebutton.png');
homebuttonup.src = "http://www.xxxxxxxxx.co.uk/images/homebutton.png" ;
homebuttondown ="buttondown"('homebuttondown.png') ;
homebuttondown.src = "http://www.xxxxxxxxxxx.co.uk/images/homebuttondown.png" ;

}
function buttondown(homebuttondown.png)
{
if (document.images) {
document[ buttonname ].src = eval( buttonname + "down.src" );
}
}
function buttonup (homebutton.png)
{
if (document.images) {
document[ buttonname ].src = eval( buttonname + "up.src" );
}
}
// -->
</script>Thanks
Danny

MoT3rror
09-03-2008, 05:10 AM
The function needs to be defined before the actually a tag. Also you don't really need all that code to change image for rollover.

http://www.java-scripts.net/javascripts/Image-Rollover-Script.phtml

dannykilla
09-03-2008, 02:27 PM
I sorted it now but thanks for the link m8

Dan