Advertisement

04.24.2008 at 03:28PM PDT, ID: 23352181 | Points: 350
[x]
Attachment Details

Why doesn't it work when I specify mouseover in onload

Tags: javascript
I have a simple javascript and a simple html --
The javascript o.js has 2 functions --
The 2 funcctions are specified in o.js --
function mouseOver()
{document.b1.src ="b_blue.gif";}
function mouseOut()
{document.b1.src ="b_pink.gif";}
 
The html --
<html>
<head>
<script type="text/javascript src="o.js"></script>
</head>
<body>
<img border="0"  src="b_pink.gif" name="b1" onmouseOver="mouseOver()" onmouseOut="mouseOut()" />
</body>
</html>

The above works fine.
if I remove the onmouseOver and onmouseOut from the img line in the html file, and specify them instead in the window.onload function in o.js,  like this
window.onload = function() {
document.b1.onmouseOver=mouseOver;
document.b1.onmouseOut=mouseOut;
}
the image swapping stops working. Can someone explain to me why it wouldn't work?
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: PurpleRice
Question Asked On: 04.24.2008
Participating Experts: 1
Points: 350
Views: 0
Translate:
Loading Advertisement...
04.24.2008 at 03:31PM PDT, ID: 21435764

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 04:10PM PDT, ID: 21435952

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 06:07PM PDT, ID: 21436411

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.28.2008 at 03:41PM PDT, ID: 21458276

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.28.2008 at 04:02PM PDT, ID: 21458379

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.29.2008 at 10:19AM PDT, ID: 21464237

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.29.2008 at 10:49AM PDT, ID: 21464452

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.02.2008 at 12:20PM PDT, ID: 21489331

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_EXPERT_20070906