• Hi Guest: Welcome to TRIBE, the online home of TRIBE MAGAZINE. If you'd like to post here, or reply to existing posts on TRIBE, you first have to register. Join us!

Javascript Help Needed

Rocky

TRIBE Member
Well, I can pretty much only paste and edit pregenerated generic lines on code, so any help would be appreciated.

I'm using a mouseover effect but, when I move my mouse over the images, they take a few seconds to load. I want to preload the images into the cache so that they can show up in the webpage almost immediately. Here's what I have:

Code:
<SCRIPT language="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) { //v3.0
  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); 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];}
}
//-->
</SCRIPT>
</HEAD>

<BODY bgcolor="#FFCC00" text="#FFFFFF" link="#FFFFFF" vlink="#999999" alink="#FFFFFF" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/nav/direct.gif','images/nav/photonav.gif','images/nav/specials.gif','images/nav/shots.gif','images/nav/dot_on.gif')" background="images/backg.gif">
<TABLE width="600" border="0" cellspacing="0" cellpadding="0">
  <TR> 
    <TD width="600"><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<img src="images/wtitle.gif" width="438" height="43" alt="" border="0" align=""></b></TD>
  </TR>
</TABLE><BR>
<TABLE width="550" border="0" cellspacing="0" cellpadding="0">
<TR> 
<TD width="19" valign="top">
<IMG src="images/nav/navlabel.gif" name="blank" width="19" height="105"><BR>
<A href="tp03a.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('blank','','images/nav/photonav.gif','Image3','','images/nav/dot_on.gif',1)">
<IMG name="Image3" border="0" src="images/nav/dot_off.gif" width="19" height="11"></A><BR>
<A href="video.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('blank','','images/nav/videonav.gif','Image4','','images/nav/dot_on.gif',1)"> 
<IMG name="Image4" border="0" src="images/nav/dot_off.gif" width="19" height="11"></A><BR> 
<A href="stuff.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('blank','','images/nav/stuffnav.gif','Image5','','images/nav/dot_on.gif',1)"> 
<IMG name="Image5" border="0" src="images/nav/dot_off.gif" width="19" height="11"></A><BR>
<A href="forum.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('blank','','images/nav/forumnav.gif','Image6','','images/nav/dot_on.gif',1)"> 
<IMG name="Image6" border="0" src="images/nav/dot_off.gif" width="19" height="11"></A><BR>
<A href="links.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('blank','','images/nav/linksnav.gif','Image7','','images/nav/dot_on.gif',1)"> 
<IMG name="Image7" border="0" src="images/nav/dot_off.gif" width="19" height="11"></A><BR>
<IMG src="images/nav/navspace.gif" width="19" height="15" border="0"></A><BR>
</TD>
<TD width="50" valign="top" rowspan="1"><IMG src="images/spacer.gif" alt="spacer" border="0" width="50" height="13"><BR>
</TD>
<TD width="255" valign="top">
 

Xtatic

TRIBE Member
If I'm reading it correctly .....

in your 'body' tag ...... the image files at the end all need to be your 'ON' buttons not the 'OFF' buttons. Give that a try, hopefully it works for ya.
 
Subscribe to Cannabis Goldsmith, wherever you get your podcasts

Xtatic

TRIBE Member
They work perfect for me ...... try forcing a refresh when you view it.

CTRL + F5 ... then see what happens.
 
Top