Rollover Buttons with pictures

naves

New Member
Messages
63
Reaction score
0
Points
0
Hey there i am wondering how i can make the pictures on my navigation have the swap effect i believe this can be done in java with ease.. does anybody have any suggestions?

I have theese two pictures could somebody give me the code so they would create the rollover effect or give me a standard format that i could fill in the file names?
that would be greatly appreciated.
 

alz4445

New Member
Messages
124
Reaction score
0
Points
0
Yeah, sure. In your header:
HTML:
<script 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];}
}
//-->
</script>

and where you want the pictures to appear, edit as necessary:
HTML:
<a href="http://LINKHERE.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Images_Unique_Name','','button_over.png',1)"><img name="Images_Unique_Name" border="0" src="button.png"></a>

I hope you know what parts to edit, just do not edit the JavaScript.
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
really? thats a stupid code

Code:
#codehere {
background-image("%pathtonavimage%");
/*more code if you want*/
}
#codehere a:hover, a:active {
background-image("%pathtorolloverimage%");
/*more code if you want*/
}

just add more of them. and use:

Code:
<a href="http://forums.x10hosting.com/graphics-webdesign/page.html"><div id="codehere"></div></a>

just replace "codehere" with w/e you used for the name of the CSS
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
javascript rollover should be dead by now, with css leading the way. only thing is that in internet explorer, you can't have img:hover, only a:hover. You can also preload the image using a:link
 
Top