/    Sign up×
Community /Pin to ProfileBookmark

onmouseover/onmouseout not working

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_DataWebGray_Button_Basic1.jpg”;
b0on = new Image();
b0on.src = “e:NBSCC_DataWebPink_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_DataWebNbscc_Aesthetician.htm”

onmouseover=”hiLite(‘b0′,’e:NBSCC_DataWebGray_Button_Basic1.jpg’)”

onmouseout=”hiLiteOff(‘b0′,’e:NBSCC_DataWebPink_Button_Basic1.jpg’)”>

<IMG src=”e:NBSCC_DataWebPink_Button_Basic1.jpg” name=”b0″ width=”77″ height=”21″ border=”0″ alt=”Aesthetician Bio”></A>
</DIV>

</body>
</html>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@torkauthorNov 10.2003 — 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.
×

Success!

Help @tork spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...