Click to See Complete Forum and Search --> : onmouseover/onmouseout not working


tork
11-09-2003, 01:45 AM
I've just begun writing in JavaScript. The code below should allow me to pass the cursor over the pink button, turn the pink button to a gray one, then send me to the new web page when I click on the button. I am testing the code on my XP system before going online, so all the file locations are local - I have checked them thoroughly. JavaScript is enabled. When I double click on the button jpgs in Windows Explorer, each image appears correctly, so I know they are in the right location and function properly.

Working: The pink button does appear when I first open the page. The link to the next page does work when I click on the pink button.

Not working: When I roll the cursor over the button, the pink button disappears and the gray button does not appear.

What am I missing here - can anybody help me? I appreciate your time. Thanks in advance.


<html>
<head>

<SCRIPT language="javascript">
<!--

// Preload universal images:

b0off = new Image();
b0off.src = "e:\NBSCC_Data\Web\Gray_Button_Basic1.jpg";
b0on = new Image();
b0on.src = "e:\NBSCC_Data\Web\Pink_Button_Basic1.jpg";

function hiLite(imgDocID,imgObjName) {
document.images[imgDocID].src = imgObjName;
}
function hiLiteOff(imgDocID,imgObjName) {
document.images[imgDocID].src = imgObjName;
}

//-->
</SCRIPT>

</head>
<body>

<DIV>
<A href="e:\NBSCC_Data\Web\Nbscc_Aesthetician.htm"

onmouseover="hiLite('b0','e:\NBSCC_Data\Web\Gray_Button_Basic1.jpg')"

onmouseout="hiLiteOff('b0','e:\NBSCC_Data\Web\Pink_Button_Basic1.jpg')">

<IMG src="e:\NBSCC_Data\Web\Pink_Button_Basic1.jpg" name="b0" width="77" height="21" border="0" alt="Aesthetician Bio"></A>
</DIV>

</body>
</html>

tork
11-09-2003, 07:30 PM
Hi Guys:
Worked it out myself ... hope this helps somebody:

The file locations for the images are assumed to be in the same (local) folder as the script is in. Thus the lines change as follows:

b0off = new Image(); b0off.src = "\Gray_Button_Basic1.jpg";
b0on = new Image(); b0on.src = "\Pink_Button_Basic1.jpg";

and to:

onmouseover="hiLite('b0','\Gray_Button_Basic1.jpg')" onmouseout="hiLiteOff('b0','\Pink_Button_Basic1.jpg')">

Note that the href address and the IMG SRC address remain as the full address on the local system.