View Full Version : Mouseovers....again


Jrfan888
05-30-2003, 01:35 AM
<script language="JavaScript">
<!-- Hide the script from old browsers --

img0_on = new Image(80,54);
img0_on.src="ab1.bmp";
img0_off = new Image(80,54);
img0_off.src="ab.bmp";

img1_on = new Image(80,54);
img1_on.src="de1.bmp";
img1_off = new Image(80,54);
img1_off.src="de.bmp";




function over_image(parm_name)
{
document[parm_name].src = eval(parm_name + "_on.src");
}
function off_image(parm_name)
{
document[parm_name].src = eval(parm_name + "_off.src");
}
// --End Hiding Here -->
</script>
</head>
<body>
<a href="yoururl.html" onmouseover="over_image('img0');" onmouseout="off_image('img0')"> <img src="ab.bmp" border="0" name="img0"></a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="yoururl.html" onmouseover="over_image('img1');" onmouseout="off_image('img1')"> <img src="de.bmp" border="0" name="img1"></a>

Is there anything wrong with this code??
Because when you mouse over one, the other moves down...?

Stormx
05-30-2003, 02:10 PM
I always use an array for mouseovers. Try using this code>



<a href="whatever.html"
onMouseOver="document.images[0].src='homeon.gif';"
onMouseOut="document.images[0].src='home.gif';">
<img src="home.gif" width=192 height=47 alt="" border="0">
</a>
<br>
<a href="whatever.html"
onMouseOver="document.images[1].src='linkson.gif';"
onMouseOut="document.images[1].src='links.gif';">
<img src="links.gif" width=93 height=42 alt="" border="0">
</a>
<br>
<a href="whatever.html"
onMouseOver="document.images[2].src='gueston.gif';"
onMouseOut="document.images[2].src='guest.gif';">
<img src="guest.gif" width=195 height=42 alt="" border="0">
</a>
<br>
<a href="whatever.html"
onMouseOver="document.images[3].src='emailon.gif';"
onMouseOut="document.images[3].src='email.gif';">
<img src="home.gif" width=185 height=42 alt="" border="0">
</a>

Jrfan888
05-30-2003, 07:46 PM
thanks...but the other mouseover image still moves down on mouseover...:sad:

Stormx
06-01-2003, 08:31 AM
Make sure your images are: The same size, and the bit which stays the same is aligned exactly with the corrasponding part on the other image

Jrfan888
06-02-2003, 05:12 PM
thank you so much! i made them the same size and it worked! :)