Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onmouseOver in Netscape (Again)

Status
Not open for further replies.

letoii

Programmer
Feb 27, 2004
4
US
I have a script for "onmouseOver" that workd in IE. I can't get it to work in Netscape. I searched the JavaScript Forum and tried all the tricks mentioned, but get the same results. If possible, plese review included code snippet.
I tried it with hardcoding values where the ASP delimiters are, but it didn't change a thing.
thanks:

Code:
<SCRIPT language=javascript>
var newsrc1;
var newsrc;
function DoImage(srcID,fldr){
    var temp1 = image1.src;
    var temp = srcID.src;
    //call function to swap sources
    getString(temp1,temp,fldr)
    image1.src = newsrc;
    srcID.src = newsrc1;
}
function getString(src1,src,fldr){
  //create new source for large photo
  arysrc = src.split("_");
  newsrc = "manager//images//" + fldr + "//" + arysrc[1]; 
  //create path for thumb
  arysrc1 = src1.split("/");
  newsrc1 = "manager//images//" + fldr + "//thumbs//thm_" + arysrc1[6];
}
</SCRIPT>
[b]body[/b]
[i]original:[/i]
<img src='<%="manager/images/"&listno&"/thumbs/thm_image3.jpg"%>' hspace="1" vspace="1" onmouseover="DoImage(image3,'<%=listno%>');" id=image3
[i]modified with Tek-Tips Tips:[/i]
<A HREF="#" onmouseover="DoImage(image2,'<%=listno%>');"><INPUT type="image" src='<%="manager/images/"&listno&"/thumbs/thm_image2.jpg"%>' hspace="1" vspace="1"  id=image2></A>

There are up to five thumbs that need swapping with the main image thus the function.
 
It might be how you're referring to the image. If you're using an IMG tag, try using document.images.image1.src and document.images[srcID].src instead of just the image name.

If you're using <input type="image" name="whatever"> you can use document.formName.whatever to get it.

Or you can add an id attribute to the image and use document.getElementById("yourImageID")


Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Here's a simpler mouseover system that I've used for years:

Here's the javascript code:
Code:
img1 = new Image(15,15);
img1.src  = "images/gold_button1.jpg";
img2 = new Image(20,20);
img2.src  = "images/gold_button.jpg";
img3 = new Image(40,40);
img3.src  = "images/testimonial_off.jpg";
img4 = new Image(40,40);
img4.src  = "images/testimonial_on.jpg";
img5 = new Image(30,30);
img5.src  = "images/roundbtn_off.jpg";
img6 = new Image(30,30);
img6.src  = "images/roundbtn_on.jpg";
img7 = new Image(61,42);
img7.src  = "images/distarrow_off.jpg";
img8 = new Image(61,42);
img8.src  = "images/distarrow_on.jpg";

function switchimage(imgDocID,imgObjName) 
{
 document[img]ocID[/img].src = eval(imgObjName + ".src");
}

And here's the HTML code:

Code:
<a href="../cgi-bin/login.pl" onmouseover="switchimage('on1','img6');" onmouseout="switchimage('on1','img5');"><img src="images/roundbtn_off.jpg" width="30" height="30" border="0" name="on1"></a>

A little explanation:
img1 = new Image(15,15); //(15,15) is image size in pixels
img1.src = "images/gold_button1.jpg"; // name of image

switchimage('on1','img6');
on1 is image name as defined in the <img> tag.
img6 is image as defined in javascript

Hope you can understand this. Also, I should mention that I put all this in an external .js file.

There's always a better way. The fun is trying to find it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top