Click to See Complete Forum and Search --> : Why wont this rollover work?
Stevinator
03-13-2004, 12:23 PM
I load the page with an image but when i do the mouseover i get an X (no image) plz help :(
<html>
<head>
<SCRIPT language="JavaScript"> if (document.images) { buttonoff = new Image() ; buttonoff.src = "C:\Documents and Settings\Steven Puroll\My Documents\My Pictures\Buttons\home1.bmp";
buttonon = new Image() ; buttonon.src ="C:\Documents and Settings\Steven Puroll\My Documents\My Pictures\Buttons\home2.bmp"; } </SCRIPT>
</head>
<body>
<A HREF = "index.htm"
onmouseover="document.img1.src = buttonon.src;")
onmouseout="document.img1.src = buttonoff.src;">
<IMG NAME = "img1" SRC = "C:\Documents and Settings\Steven Puroll\My Documents\My Pictures\Buttons\home1.bmp">
</body>
</html>
Pittimann
03-13-2004, 12:45 PM
Hi!
Your code is not "clean", but nevertheless, the image should show up. Most likely, home2.bmp doesn't exist in the folder you specified.
Concerning your code, you better try something like this:
<A HREF = "index.htm"><IMG NAME = "img1" SRC = "C:\Documents and Settings\Steven Puroll\My Documents\My Pictures\Buttons\home1.bmp" onmouseover="this.src = buttonon.src;" onmouseout="this.src = buttonoff.src;"></a>
Cheers - Pit
Exuro
03-13-2004, 12:49 PM
It worked fine for me... But, the first thing I did was changed your images (home1.bmp and home2.bmp) to GIF images. I did this because Bitmap images (BMP) are not supported by all browsers, not to mention that they take much longer to download... I then changed your absolute path to the images to a relative one. So when I was done I had this:
<html>
<head>
<SCRIPT language="JavaScript">
if (document.images) {
buttonoff = new Image(); buttonoff.src = "Buttons/home1.gif";
buttonon = new Image(); buttonon.src ="Buttons/home2.gif";
}
</SCRIPT>
</head>
<body>
<A HREF="index.htm"
onmouseover="document.img1.src = buttonon.src;"
onmouseout="document.img1.src = buttonoff.src;">
<IMG NAME="img1" SRC="Buttons/home1.gif">
</A>
</body>
</html>
So there are two things that I would recommend you do. Convert your images to GIF format rather than BMP, and then be sure that the folder "Buttons" is located in the same directory that contains your HTML page. Hope that helps!
Stevinator
03-13-2004, 03:35 PM
mmm tried yours and now the button only shows when the cursor is over it
Exuro
03-13-2004, 03:50 PM
I believe that would mean that the path to the image home1.gif is incorrect. Double-check that it's really there.
Stevinator
03-13-2004, 03:52 PM
its definately there... ive checked and rechecked. I hate it when code just decides not to work :mad:
Exuro
03-13-2004, 04:09 PM
It's not the code... If the image isn't displaying until you put the mouse over it then that means the page can't find the image in the SRC="" attribute. Is your page posted on the internet, or is it on your computer? Did you convert the images to GIFs? You might've accidently not converted one, incorrectly named it, or forgot to update the code...