Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

swap images but display one only first time

Status
Not open for further replies.

onressy

Programmer
Mar 7, 2006
421
CA
hi, i using the dreamweaver swap image function, i have small boxes at teh bottom of the page which on mouseover, the bigger picture gets exchanged for another, i would like to display a bigger image when the page loads but only for the initial time, then when swapping starts never display that image again, this is the code i'm using:
Code:
<script language="JavaScript" type="text/JavaScript">
<!--
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];}
}

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;
}
//-->
</script>

///in the html:

Code:
           <tr>
              <td valign="middle" class="center"><table align="center" id="tableRollovers" >
                <tr>
                  <td><img src="images/whitebox.gif" width="17" height="18"></td>
                  <td><a href="javascript:" onMouseOver="MM_swapImage('children','','images/children/children1.jpg','box1','','images/boxOver.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/boxOut.gif" name="box1" width="17" height="18" border="0" id="box1"></a></td>
                  <td><a href="javascript:" onMouseOver="MM_swapImage('children','','images/children/children2.jpg','box2','','images/boxOver.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/boxOut.gif" name="box2" width="17" height="18" border="0" id="box2"></a></td>
                  <td><a href="javascript:" onMouseOver="MM_swapImage('children','','images/children/children3_more.jpg','box3','','images/boxOver.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/boxOut.gif" name="box3" width="17" height="18" border="0" id="box3"></a></td>
                  <td><a href="javascript:" onMouseOver="MM_swapImage('children','','images/children/children4.jpg','box4','','images/boxOver.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/boxOut.gif" name="box4" width="17" height="18" border="0" id="box4"></a></td>
                  <td><a href="javascript:" onMouseOver="MM_swapImage('children','','images/children/children5.jpg','box5','','images/boxOver.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/boxOut.gif" name="box5" width="17" height="18" border="0" id="box5"></a></td>
                  <td><a href="javascript:" onMouseOver="MM_swapImage('children','','images/children/children6.jpg','box6','','images/boxOver.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/boxOut.gif" name="box6" width="17" height="18" border="0" id="box6"></a></td>
                  <td><a href="javascript:" onMouseOver="MM_swapImage('children','','images/children/children7.jpg','box7','','images/boxOver.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/boxOut.gif" name="box7" width="17" height="18" border="0" id="box7"></a></td>
                  <td><a href="javascript:" onMouseOver="MM_swapImage('children','','images/children/children8.jpg','box8','','images/boxOver.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/boxOut.gif" name="box8" width="17" height="18" border="0" id="box8"></a></td>
                  <td><a href="javascript:" onMouseOver="MM_swapImage('children','','images/children/children9.jpg','box9','','images/boxOver.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/boxOut.gif" name="box9" width="17" height="18" border="0" id="box9"></a></td>
                  <td><a href="javascript:" onMouseOver="MM_swapImage('children','','images/children/children10_more.jpg','box10','','images/boxOver.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/boxOut.gif" name="box10" width="17" height="18" border="0" id="box10"></a></td>
                  <td><a href="javascript:" onMouseOver="MM_swapImage('children','','images/children/children11.jpg','box11','','images/boxOver.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/boxOut.gif" name="box11" width="17" height="18" border="0" id="box11"></a></td>
                  <td><a href="javascript:" onMouseOver="MM_swapImage('children','','images/children/children12.jpg','box131','','images/boxOver.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/boxOut.gif" name="box131" width="17" height="18" border="0" id="box12"></a></td>
                  <td><a href="javascript:" onMouseOver="MM_swapImage('children','','images/children/children.jpg','box13','','images/boxOver.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/boxOut.gif" name="box13" width="17" height="18" border="0" id="box12"></a></td>
                  <td><img src="images/whitebox.gif" width="17" height="18"></td>
                </tr>
              </table></td>
            </tr>
 
I don't understand what's stopping you (because I have no idea how the code for the big image looks, because you haven't pointed it out).

Why not simply put the URL to the big image on the page so it loads with the page?

Dan


Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top