The Mother Board

Motherboards.org forums. Free tech support, motherboard ID, and more.
It is currently Mon Oct 15, 2018 10:11 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: javascript help
PostPosted: Mon Aug 16, 2004 9:52 pm 
Offline
Lead Mobo-fu Master
Lead Mobo-fu Master

Joined: Sun Dec 16, 2001 1:01 am
Posts: 14303
Location: Maine
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>

<TITLE>Untitled</TITLE>
<link rel="STYLESHEET" type="text/css" href="./../../common/cstechstyle.css">
</head>

<body bgcolor="#999999" text="white" link="white" vlink="white" alink="white">

<SCRIPT language="javascript1.1">

   infoOn = new Image()
   infoOn.src = "./../../images/getinfodown.gif"

   infoOff = new Image()
   infoOff.src = "./../../images/getinfoup.gif"

function changeImg(cImg,ref) {
document.images[cImg].src = ref.src
}
</SCRIPT><table width="100%" border="0">




<tr>
<td align="left" valign="top" class="submenuheading"><a href="sidenav.html"><font color="yellow">Back</font></a></td></tr>

       <tr><td height="50"></td></tr>

   <tr><td align="center" valign="top" class="submenuheading">Quickspecs</td></tr>

   
         <tr>
<td align="center" valign="top">
<a href="5bw1xx/5bw112/5BW112quickspecs.html" target="content"
onMouseOver="changeImg('info',infoOn)"
onMouseOut="changeImg('info',infoOff)">
<img name=info src="./../../images/getinfoup.gif" border=0></a></td> </tr><BR>

<tr><td height="50"></td></tr>

   <tr><td align="center" valign="top" class="submenuheading">Heading 2</td></tr>


         <tr>
<td align="center" valign="top">
<a href="5bw1xx/5bw112/5BW112quickspecs.html" target="content"
onMouseOver="changeImg('info',infoOn)"
onMouseOut="changeImg('info',infoOff)">
<img name=info src="./../../images/getinfoup.gif" border=0></a></td> </tr><BR>


</table>
</html>


I needing to get the above code working properly or have it redone to work properly. I cannot get it figured out at all. The above code works properly if I remove the entire "Heading 2" block from the code.

thanks for any help...

_________________
Compaq-Fu Master
Ctechinfo funding drive information


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 19, 2004 9:51 am 
Offline
Initiate
Initiate

Joined: Tue Mar 25, 2003 5:49 pm
Posts: 85
I'm not as deep into javascript as you appear to be, but I have a couple of questions.

What exactly are you trying to accomplish? Do you want the image to change when the OnMouseOver event occurs and that isn't working?

I can't replicate your page and troubleshoot as I don't have access to the style sheet or the images.

Shouldn't the <script> tags be in the <head> section?

Once I have a better idea of what is supposed to happen and what isn't happening, I may be able to help troubleshoot a bit. Do you have a URL I could go to and check out the page itself?

tryn


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Aug 19, 2004 12:59 pm 
Offline
Lead Mobo-fu Master
Lead Mobo-fu Master

Joined: Sun Dec 16, 2001 1:01 am
Posts: 14303
Location: Maine
Will have a url availible later on this evening......I have moved the <script> block into the <head> tags as suggested and made no difference.

Quote:
What exactly are you trying to accomplish? Do you want the image to change when the OnMouseOver event occurs and that isn't working?
What I am trying to accomplish is a universal code that I can adjust when needed to work with one or two rollover "instances". What I end up with now (when trying to have 2 rollover "instances"), is I roll the mouse over link/image 1 and link/image 2 lights up. When its just one link/image everything works flawlessly.. :roll:

_________________
Compaq-Fu Master
Ctechinfo funding drive information


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Aug 19, 2004 2:17 pm 
Offline
Lead Mobo-fu Master
Lead Mobo-fu Master

Joined: Sun Dec 16, 2001 1:01 am
Posts: 14303
Location: Maine
http://www.s87841630.onlinehome.us/quic ... bw112.html

_________________
Compaq-Fu Master
Ctechinfo funding drive information


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Aug 19, 2004 2:44 pm 
Offline
Black Belt
Black Belt

Joined: Tue Oct 22, 2002 9:07 pm
Posts: 584
Location: Melbourne, Australia
I don't have time atm to error check your code, but this is the rollover script I use, if you want it. It's originally from dreamweaver, but found it to work well, so I use it even when hard coding.

This goes in the <head>
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) { //v4.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);
  if(!x && document.getElementById) x=document.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>


Use the <body> tag to preload your rollover images:
Code:
<body bgcolor="#FFFFFF" text="#000000" onLoad="MM_preloadImages('images/image_up.jpg')">


Then your img tag looks like this:
Code:
<a href="link.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Rollover1','','images/image_up.jpg',1)"><img name="Rollover1" border="0" src="images/image_down.jpg"></a>

_________________
"I disapprove of what you say, but I will defend to the death your right to say it"

-Voltaire


Top
 Profile  
Reply with quote  
 Post subject: Re: javascript help
PostPosted: Thu Aug 19, 2004 2:53 pm 
Offline
Black Belt
Black Belt

Joined: Tue Oct 22, 2002 9:07 pm
Posts: 584
Location: Melbourne, Australia
I think I just figured your problem: Both your images are named 'info'. Change the code for the second image to this, it should work:
Code:
<a href="5bw1xx/5bw112/5BW112quickspecs.html" target="content"
onMouseOver="changeImg('info2',infoOn)"
onMouseOut="changeImg('info2',infoOff)">
<img name=info2 src="./../../images/getinfoup.gif" border=0></a>

_________________
"I disapprove of what you say, but I will defend to the death your right to say it"

-Voltaire


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Aug 19, 2004 3:00 pm 
Offline
Lead Mobo-fu Master
Lead Mobo-fu Master

Joined: Sun Dec 16, 2001 1:01 am
Posts: 14303
Location: Maine
ok thanks a bunch...

you don't happen to post over at webmaster-talk.com do you?

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<BASE HREF="http://www.s87841630.onlinehome.us/">
<TITLE>Untitled</TITLE>
<link rel="STYLESHEET" type="text/css" href="common/cstechstyle.css">
<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) { //v4.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);
if(!x && document.getElementById) x=document.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>
</head>
<body bgcolor="#999999" text="white" link="white" vlink="white" alink="white"

onLoad="MM_preloadImages('/images/getinfodown.gif')">
<SCRIPT language="javascript1.1">

infoOn = new Image()
infoOn.src = "images/getinfodown.gif"

infoOff = new Image()
infoOff.src = "images/getinfoup.gif"

function changeImg(cImg,ref) {
document.images[cImg].src = ref.src
}
</SCRIPT>
<table width="100%" border="0">
<tr>
<td align="left" valign="top" class="submenuheading"><a href="sidenav.html"><font

color="yellow">Back</font></a></td>
</tr>
<tr>
<td height="50"></td>
</tr>
<tr>
<td align="center" valign="top" class="submenuheading">Quickspecs</td>
</tr>
<tr>
<td align="center" valign="top"> <a href="PC Theater/9100/9100quickspecs.html"

target="content"
onMouseOver="changeImg('info',infoOn)"
onMouseOut="changeImg('info',infoOff)"> </a><a

href="PC%20Theater/9100/sytemboard.html" onMouseOut="MM_swapImgRestore()"

onMouseOver="MM_swapImage('Image2','','/images/getinfodown.gif',1)"><img

name="Image2" border="0" src="/images/getinfoup.gif" width="103"

height="12"></a></td>
</tr>
<BR>
<BR>
<tr>
<td align="center" valign="top" class="submenuheading">Jumpers</td>
</tr>
<tr>
<td align="center" valign="top"> <a href="PC Theater/9100/sytemboard.html"

target="content"
onMouseOver="changeImg('info',infoOn)"
onMouseOut="changeImg('info',infoOff)"> <img name=info src="images/getinfoup.gif"

border=0></a></td>
</tr>
<BR>
</table>
</html>


That is what I got from a member there. Seems to work perfectly when the links are properly setup........... :oops:
When seting this above code up I failed to notice the BASE href. Thus throwing everything else off... :roll:

Between the two codes I should be good to go now... 8)

_________________
Compaq-Fu Master
Ctechinfo funding drive information


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Aug 19, 2004 3:38 pm 
Offline
Black Belt
Black Belt

Joined: Tue Oct 22, 2002 9:07 pm
Posts: 584
Location: Melbourne, Australia
Nah, that wasn't me :D

I guess that script is pretty popular thanks to dreamweaver. It works well across browsers, and preloads the images, which is what I like.

Hope it works out for ya.

_________________
"I disapprove of what you say, but I will defend to the death your right to say it"

-Voltaire


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Aug 19, 2004 5:34 pm 
Offline
Lead Mobo-fu Master
Lead Mobo-fu Master

Joined: Sun Dec 16, 2001 1:01 am
Posts: 14303
Location: Maine
Well except for rewriting a bunch of code things are starting to lookup for this project.... :D

thanks again for the help..

_________________
Compaq-Fu Master
Ctechinfo funding drive information


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group