...

View Full Version : stopPropogation - event bubble cancel



Choopernickel
04-01-2003, 08:54 PM
:confused:

I'm trying to use event.stopPropogation() in a script that I don't need in Mozilla-based browsers (the CSS takes care of it). However, the snippet still throws an error. How do I detect the actual event object in Mozilla(etc.) to stop its propogation?



try {
event.stopPropagation();
return;
} catch (err) {
ignore="this error";
}


Thanks for any help or pointers.

[edit:] by throwing the error, I mean to say that Mozilla sets the ignore variable to the value "this error."

jkd
04-01-2003, 10:33 PM
Let's see the function this in. There is no global event object in a DOM2-compliant browser - the event instance is passed around as an argument.

Choopernickel
04-01-2003, 10:38 PM
Here's the important part, all fixed up:


// MakeMenu(el)
// shows the children of the passed element
// el = element whose children to show
// ev = event which should be cancelled.
function MakeMenu(el, ev) {
/* menu works through css in mozilla-based browsers; eventually this script will be completely unnecessary everywhere, as it is in mozilla */
try {
ev.stopPropagation();
return;
} catch (err) {
caught=0;
}
...
}


Now I've got different problems, and I'll start a different thread.

jkd
04-02-2003, 09:25 PM
ev then el, not the other way around. The event instance is always the first argument.

Choopernickel
04-02-2003, 09:27 PM
Well, I'm calling it as MakeMenu(this, event), so I figured it would be the same. It seems to work the same.

I got this working with the adjustment I made yesterday.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum