Click to See Complete Forum and Search --> : Mouseover pic change


UnRealKreationz
12-20-2002, 10:26 PM
Does anyone know the code for if I have 2 pics that are the same size, and I want to create a mouseover effect so that the first pic changes to the second pic?? It would really help me out, thanx!

pyro
12-20-2002, 10:37 PM
This is to preload you images. This code goes in your <head>

<SCRIPT LANGUAGE="javascript">
<!--Hide

name_off=new Image(93,18)
name_off.src="name_off.gif"
name_on=new Image(93,18)
name_on.src="name_on.gif"

//End hide-->
</Script>

This is where you want your images on the page. This goes in your <body>

<A HREF="name.html" onmouseover="document.whatever.src=name_on.src" onmouseout="document.whatever.src=name_off.src"><IMG SRC="name_off.gif" NAME="whatever" BORDER=0 HEIGHT=18 WIDTH=93></A>


Any questions??

UnRealKreationz
12-21-2002, 05:41 PM
This is what I changed it to, but it's not working for me. Can you show me what I did wrong??

<Head>
<SCRIPT LANGUAGE="javascript">
<!--Hide

name_off=HomeOFF(150,50)
name_off.src="HomeOFF.gif"
name_on=HomeON(150,50)
name_on.src="HomeON.gif"

//End hide-->
</Script>

<Body>
<A HREF="index.html" onmouseover="HomeON.gif.src=name_on.src" onmouseout="HomeOFF.gif.src=name_off.src"><IMG SRC="HomeOFF.gif" NAME="Home" BORDER=0 HEIGHT=50 WIDTH=150></A>

pyro
12-21-2002, 09:15 PM
In my above script, the document.whatever.src should read document.(the value you gave your name attribute for your image here).src. OK?

Also if I were you, I'd rename my images to all lowercase...A good habit to get into. If you rename your images to homeoff.gif and homeon.gif, the following script should work for you.

<html>
<head>
<SCRIPT LANGUAGE="javascript">
<!--Hide

home_off=new Image(150,50)
home_off.src="homeoff.gif"
home_on=new Image(150,50)
home_on.src="homeon.gif"

//End hide-->
</Script>
</head>
<body>
<A HREF="index.html" onmouseover="document.home.src=name_on.src" onmouseout="document.home.src=name_off.src"><IMG SRC="homeoff.gif" NAME="home" BORDER=0 HEIGHT=50 WIDTH=150></A>
</body>
</html>

UnRealKreationz
12-22-2002, 03:45 PM
thanx a lot for the code. it really helped me out.

pyro
12-22-2002, 03:58 PM
Did you see what you did wrong? If not, I can explain if you'd like.

UnRealKreationz
12-23-2002, 01:48 PM
yes, i see what i did wrong. I have just one last question, is there a way i can make all my buttons go across the top in a row instead of straight down??

Zach Elfers
12-23-2002, 01:52 PM
<img src="img.gif" align="left"><img src="img.gif" align="center"><img src="img.gif" align="right">

pyro
12-23-2002, 02:01 PM
I'm not sure exactly what you mean. If what Zach said isn't what you are looking for, please explain a bit more, and I'll try to help. :)