PDA

View Full Version : using onMouseover


adam52
04-15-2004, 03:01 PM
whats up everyone?

I am having a problem using onMouseover in javascript. I think that i have it set up right. The problem i am having is that when the page loads, it doesnt show the image, it shows a box with an x in the corner. But once you put your mouse over it it shows up and stays visible and also swithched images when the mouse is over it.

<script LANGUAGE="JavaScript"><!--// preload images:if (document.images)

{home1 = new Image(163,43);home1.src="images/home1.gif";
home2 = new Image(163,43);home2.src="images/home2.gif";}
{projects1 = new Image(163,43);projects1.src="images/projects1.gif";
projects2 = new Image(163,43);projects2.src="images/projects2.gif";}
{ftp1 = new Image(163,43);ftp1.src="images/ftp1.gif";
ftp2 = new Image(163,43);ftp2.src="images/ftp2.gif";}

function hiLite(imgName,imgObjName) {if (document.images)

{document.images[imgName].src = eval(imgObjName + ".src");}}

//--></script>

<A HREF="index.html" onMouseOver="hiLite('img01','home1')" onMouseOut="hiLite('img01','home2')"><IMG SRC="home1.gif" BORDER="0" ALT="" NAME="img01" width="150" height="50"></A>
<A HREF="projects.html" onMouseOver="hiLite('img02','projects1')" onMouseOut="hiLite('img02','projects2')"><IMG SRC="projects1.gif" BORDER="0" ALT="" NAME="img02" width="150" height="50"></A>
<a TARGET=_new href="ftp://ftp.jndetail.com" onMouseOver="hiLite('img03','ftp1')" onMouseOut="hiLite('img03','ftp2')"><IMG SRC="ftp1.gif" BORDER="0" ALT="" NAME="img03" width="150" height="50"></A>

here is the code that it running it. You can also view source it at www.jndetail.com. Any suggestions.
Thanks

agent002
04-15-2004, 03:04 PM
After a quick look at the JavaScript, I noticed that
<IMG SRC="ftp1.gif" ....
should be
<IMG SRC="images/ftp1.gif" ....
:)

eRad
04-15-2004, 03:32 PM
also i'm assuming you would also need to add the images/ to the following lines:

<IMG SRC="home1.gif" BORDER="0" ALT="" NAME="img01" width="150" height="50">
<IMG SRC="projects1.gif" BORDER="0" ALT="" NAME="img02" width="150" height="50">

agent002
04-15-2004, 03:33 PM
well, yeah. I was just giving an example.

adam52
04-15-2004, 03:49 PM
THanks for the replys. That solved the problem
Thanks again.
adam