View Full Version : Roll Over Image Problem


Tailtiu
08-22-2004, 07:32 PM
Hello everyone,

I'm an amateur designer needing some advice please.

I am trying to use the roll over function with mouse over etc.

I have images all the same size and I'm trying to change the image on mouse over
to a slightly bigger image.

I'm using your basic .js & my images are set in layers the same size as the first image.

This is where my problem lies; I cannot get my mouse to show the bigger image on mouse over.

I presume it has something to do with using layers. I was reading a book about it and saw a <span></span> tag used in another instance.

Will this work for what I'm trying to do? If so what is the proper positioning of the span tags in the .js as follows.

<div id="Box2"><a href="default.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image3','','images/fun_2.gif',1)"><img src="images/fun_1.jpg" alt="have fun on the jet ski" name="Image3" width="115" height="115" border="0" id="Image3" /></a></div>

Thank you so much for your help.

Tailtiu

pb&j
08-22-2004, 10:01 PM
can you provide a link to your page having the problem? it may be in the javascript function itself.

Tailtiu
08-22-2004, 11:29 PM
Hello,

Thanks for trying to help. I'm far from being done yet with my site and haven't uploaded it yet.

I'm using a layer <div> size of 115 x 115 and image size of same.
My mouse over image is 120 x 120 . This image will not expand when the mouse is over it.

I've tried to tweak my .css doc position settings using every combonation I could think of without progress.

Here is the script I'm using in a .js doc with a link in my <head> tags

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
____________________________________________-
This is my <div> tags

<div id="Box2"><a href="default.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image3','', 'images/fun_2.gif',1)"><img src="images/fun_1.jpg" alt="have fun on the jet ski" name="Image3" width="115" height="115" border="0" id="Image3" /></a></div>
__________________________________________________ _______________---

Thanks again for your help. :rolleyes: