/    Sign up×
Community /Pin to ProfileBookmark

dynamically adding onmouseup to body

Hi,

I want to add an onMouseUp-Event to the body tag. (IE 5.x)
It is important for me, that this is not done in the html-file but in an js file. I tried to do something like this:

var body = document.getElementsByTagName(“body”)[0];
body.onMouseUp = myOnMouseUp;

where myOnMouseUp is a valid function.
This works fine with the event onMouseDown but not with onMouseUp (with Netscape-Navigator it works but not with IE5.x)… can you help me or explain why?

Thx in advance

Ulukai

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsDec 13.2002 — this will probably do it

var myBody = document.getElementById('isBody');

myBody.onMouseUp = myOnMouseUp;

you should you onFocus or onBlur

the body doesn't have a onMouse or a onClick event

when you add [0] to the body element it getting the first element in the body array
Copy linkTweet thisAlerts:
@gil_davisDec 13.2002 — [font=courier]

if (!document.all)

{document.captureEvents(Event.MOUSEUP);}

document.onmouseup = myUp;

function myUp() {

alert("Up!");

}[/font]

Tested in IE 5.5, NS 4.8 and NS 6.2.
Copy linkTweet thisAlerts:
@UlukaiauthorDec 14.2002 — Thanks that worked fine.

As I looked over my code, I discovered the real error, the problem is solved now.

CU

Ulukai
×

Success!

Help @Ulukai 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.25,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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