The Arcive of vBulletin Modifications Site. |
|
|
#1
|
|||
|
|||
|
Hey all,
I have been trying to code some rollover buttons on my forum but something seems to go wrong, can you help me figure out what exactly? In headeInclude: Code:
<script type="text/javascript">
<!--
if (document.images)
{
image1on = new Image();
image1on.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/home.gif";
image1off = new Image();
image1off.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/home_over.gif";
image2on = new Image();
image2on.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/forum.gif";
image2off = new Image();
image2off.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/forum_over.gif";
image3on = new Image();
image3on.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/usercp.gif";
image3off = new Image();
image3off.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/usercp_over.gif";
image4on = new Image();
image4on.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/arcade.gif";
image4off = new Image();
image4off.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/arcade_over.gif";
image5on = new Image();
image5on.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/chat.gif";
image5off = new Image();
image5off.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/chat_over.gif";
image6on = new Image();
image6on.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/members.gif";
image6off = new Image();
image6off.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/members_over.gif";
image7on = new Image();
image7on.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/faq.gif";
image7off = new Image();
image7off.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/faq_over.gif";
image8on = new Image();
image8on.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/affiliates.gif";
image8off = new Image();
image8off.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/affiliates_over.gif";
image9on = new Image();
image9on.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/topsites.gif";
image9off = new Image();
image9off.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/topsites_over.gif";
image10on = new Image();
image10on.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/logout.gif";
image10off = new Image();
image10off.src = "http://www.bratz-designs.com/forums/images/afterdark/misc/logout_over.gif";
}
function changeImages()
{
if (document.images)
{
for (var i=0; i<changeImages.arguments.length; i+=2)
{
document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");
}
}
}
// -->
</script>
Code:
<td width="100%" height="33" align="left" valign="top" style="background-image:url($stylevar[imgdir_misc]/xnav.gif)"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top" width="79" height="33"><a href="http://www.bratz-designs.com" onmouseover="changeImages('image1', 'image1off')" onmouseout="changeImages('image1', 'image1on')><img src="http://www.bratz-designs.com/forums/images/afterdark/misc/home.gif" width="79" height="33" name="image1" border="0" alt="Home" 'image1on'/></a></td>
<td align="left" valign="top" width="79" height="33"><a href="http://www.bratz-designs.com/forums/index.php" onmouseover="changeImages('image2', 'image2off')" onmouseout="changeImages('image2', 'image2on')><img src="http://www.bratz-designs.com/forums/images/afterdark/misc/forum.gif" width="79" height="33" name="image2" border="0" alt="Forum" 'image2on'/></a></td>
<td align="left" valign="top" width="79" height="33"><a href="http://www.bratz-designs.com/forums/usercp.php$session[sessionurl_q]" onmouseover="changeImages('image3', 'image3off')" onmouseout="changeImages('image3', 'image3on')><img src="http://www.bratz-designs.com/forums/images/afterdark/misc/usercp.gif" width="79" height="33" name="image3" border="0" alt="UserCp" 'image3on'/></a></td>
<td align="left" valign="top" width="79" height="33"><a href="http://www.bratz-designs.com/forums/arcade.php$session[sessionurl_q]" onmouseover="changeImages('image4', 'image4off')" onmouseout="changeImages('image4', 'image4on')><img src="http://www.bratz-designs.com/forums/images/afterdark/misc/arcade.gif" width="79" height="33" name="image4" border="0" alt="Arcade" 'image4on'/></a></td>
<td align="left" valign="top" width="79" height="33"><a href="http://www.bratz-designs.com/forums/javachat.php$session[sessionurl_q]" onmouseover="changeImages('image5', 'image5off')" onmouseout="changeImages('image5', 'image5on')><img src="http://www.bratz-designs.com/forums/images/afterdark/misc/chat.gif" width="79" height="33" name="image5" border="0" alt="Chat" 'image5on'/></a></td>
<td align="left" valign="top" width="79" height="33"><a href="http://www.bratz-designs.com/forums/memberlist.php$session[sessionurl_q]" onmouseover="changeImages('image6', 'image6off')" onmouseout="changeImages('image6', 'image6on')><img src="http://www.bratz-designs.com/forums/images/afterdark/misc/members.gif" width="79" height="33" name="image6" border="0" alt="Members" 'image6on'/></a></td>
<td align="left" valign="top" width="79" height="33"><a href="http://www.bratz-designs.com/forums/affiliates.php$session[sessionurl_q]" onmouseover="changeImages('image8', 'image8off')" onmouseout="changeImages('image8', 'image8on')><img src="http://www.bratz-designs.com/forums/images/afterdark/misc/affiliates.gif" width="79" height="33" name="image8" border="0" alt="Affiliates" 'image8on'/></a></td>
<td align="left" valign="top" width="79" height="33"><a href="http://www.bratz-designs.com/forums/toplist.php$session[sessionurl_q]" onmouseover="changeImages('image9', 'image9off')" onmouseout="changeImages('image9', 'image9on')><img src="http://www.bratz-designs.com/forums/images/afterdark/misc/topsites.gif" width="79" height="33" name="image9" border="0" alt="Toplist" 'image9on'/></a></td>
<td align="left" valign="top" width="79" height="33"><a href="http://www.bratz-designs.com/forums/faq.php$session[sessionurl_q]" onmouseover="changeImages('image7', 'image7off')" onmouseout="changeImages('image7', 'image7on')><img src="http://www.bratz-designs.com/forums/images/afterdark/misc/faq.gif width="79" height="33" name="image7" border="0" alt="" 'image7on'"/></a></td>
<if condition="$show['member']">
<td align="left" valign="top" width="79" height="33"><a href="http://www.bratz-designs.com/forums/login.php?$session[sessionurl]do=logout&logouthash=$bbuserinfo[logouthash]" onclick="return log_out() onmouseover="changeImages('image10', 'image10off')" onmouseout="changeImages('image10', 'image10on')"><img src="http://www.bratz-designs.com/forums/images/afterdark/misc/logout.gif" width="79" height="33" name="image10" border="0" alt="" 'image10on'/></a></td>
</if>
|
|
#2
|
||||
|
||||
|
Rollovers work like this..
Code:
<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>
<body onLoad="MM_preloadImages('http://www.bratz-designs.com/forums/images/afterdark/misc/logout_over.gif')"><a href="http://gohere" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','http://www.bratz-designs.com/forums/images/afterdark/misc/logout_over.gif',1)"><img src="http://www.bratz-designs.com/forums/images/afterdark/misc/logout.gif" name="Image1" width="80" height="33" border="0"></a>
|
|
#3
|
|||
|
|||
|
http://chrispoole.com/scripts/javasc...mage-rollover/
This works great for me in the past. Up the js file(possibly to your clientscript directory). Then add PHP Code:
|
|
#4
|
||||
|
||||
|
Wouldn't CSS be an easier and less resource-consuming alternative? Seems like a LOT of code just for rollover images.
|
|
#5
|
|||
|
|||
|
Try this instead. It is an old vB 2 hack but works great to this day.
|
|
#6
|
|||
|
|||
|
Quote:
EDIT: Only works on vbadvanced homepage ............ any ideas ? EDIT AGAIN: Added code to the bottom of forumhome is now working there also. |
|
#7
|
|||
|
|||
|
Quote:
Quote:
ta anyone ??? |
|
#8
|
|||
|
|||
|
gee thanks...
|
|
#9
|
||||
|
||||
|
As Aken has stated, why not use CSS to manage these things, the images can automatically preload as well.
|
|
#10
|
||||
|
||||
|
Thank you X!
|
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|