rollover effect help

Joined
Apr 29, 2005
Messages
6,400
Reaction score
130
well this is my code, but for some reason it doesn't work, if someone can point out the flaw i would be really gratefull

Code:
<head>
<script language="JavaScript" type="text/javascript">
<!--
if (document.images) {
    homebuttonup       = new Image();
    homebuttonup.src   = "home.jpg" ;
    homebuttondown     = new Image() ;
    homebuttondown.src = "home2.jpg" ;

    aboutbuttonup       = new Image();
    aboutbuttonup.src   = "aboutbutton.gif" ;
    aboutbuttondown     = new Image() ;
    aboutbuttondown.src = "aboutbuttondown.gif" ;
}
function buttondown( home2 )
{
    if (document.images) {
      document[ home2 ].src = eval( home2 + "down.src" );
    }
}
function buttonup ( buttonname )
{
    if (document.images) {
      document[ home ].src = eval( home + "up.src" );
    }
}
// -->
</script>
</head>
  
<a href="index.html"
  onmouseover="buttondown('home.jpg')"
  onmouseout="buttonup('home2.jpg')">
<img src="home.jpg" name="home2" border="0" id="home2" style="position: absolute; left: 624px; top: 157px;" /></a>

-note, home.jpg is the original image, home2.jpg is the image that needs to be replaced when the mouse goes over it
 
What you do is make a new image object, then assign certain properties to it, then use a function of the image class on it.

Now, without the image class, that won't work ;) But I don't know much about javascript so it could be its a default class, but if its not, you'll have to include it somewhere :)
 
What you do is make a new image object, then assign certain properties to it, then use a function of the image class on it.

Now, without the image class, that won't work ;) But I don't know much about javascript so it could be its a default class, but if its not, you'll have to include it somewhere :)

i'm sure you know more about java then me xD, anyway i'll look up some tutorials and figure it out
 
Back