vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Design and Graphics Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=168)
-   -   rollover buttons (https://vborg.vbsupport.ru/showthread.php?t=139092)

Bratz-Designs 02-11-2007 10:18 AM

rollover buttons
 
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>

In header template:
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&amp;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>


WEBDosser 02-11-2007 10:40 AM

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>

maybe you could modify that code to work on your header template

Xplorer4x4 02-12-2007 06:28 PM

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:

<script type="text/javascript" src="dom_image_rollover_hover.js"></script

to the headinclude. It may also work by just using it in the header template itself. Been awhile since i used it but if you need help drop me a pm.

Aken 02-14-2007 04:56 AM

Wouldn't CSS be an easier and less resource-consuming alternative? Seems like a LOT of code just for rollover images.

Xplorer4x4 03-15-2007 09:13 PM

1 Attachment(s)
Try this instead. It is an old vB 2 hack but works great to this day.

bigdog829 03-15-2007 11:34 PM

Quote:

Originally Posted by Xplorer4x4 (Post 1204408)
Try this instead. It is an old vB 2 hack but works great to this day.

Thanks alot worked like a charm :up:

EDIT: Only works on vbadvanced homepage ............ any ideas ?

EDIT AGAIN: Added code to the bottom of forumhome is now working there also.

majorj0nny 07-19-2007 10:39 PM

Quote:

Originally Posted by Xplorer4x4 (Post 1204408)
Try this instead. It is an old vB 2 hack but works great to this day.

thats a great hack and works well for anything with 'img src' infront of it ... but I use some paypal buttons that start with

Quote:

<input type="image" src="image location" border="0" name="submit" alt="PLEASE HELP - Donate to our Ranked Server Fund!">
and adding the necessary line to that does not work - anyone know how I edit the stuff in the header include to include these 'form' buttons as images?

ta

anyone ???

majorj0nny 08-08-2007 08:38 PM

gee thanks...

Dismounted 08-09-2007 07:28 AM

As Aken has stated, why not use CSS to manage these things, the images can automatically preload as well.

CLF 08-08-2008 04:11 AM

Thank you X! :)


All times are GMT. The time now is 08:13 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01826 seconds
  • Memory Usage 1,781KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete