Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-01-2003, 07:54 PM   PM User | #1
Choopernickel
Regular Coder

 
Join Date: Apr 2003
Location: Atlanta, GA
Posts: 487
Thanks: 0
Thanked 0 Times in 0 Posts
Choopernickel is an unknown quantity at this point
Angry stopPropogation - event bubble cancel



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?

Code:
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."
Choopernickel is offline   Reply With Quote
Old 04-01-2003, 09:33 PM   PM User | #2
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
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.
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 04-01-2003, 09:38 PM   PM User | #3
Choopernickel
Regular Coder

 
Join Date: Apr 2003
Location: Atlanta, GA
Posts: 487
Thanks: 0
Thanked 0 Times in 0 Posts
Choopernickel is an unknown quantity at this point
okay, maybe not complete DOM

Here's the important part, all fixed up:
Code:
// 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.

Last edited by Choopernickel; 04-02-2003 at 03:47 PM..
Choopernickel is offline   Reply With Quote
Old 04-02-2003, 08:25 PM   PM User | #4
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
ev then el, not the other way around. The event instance is always the first argument.
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 04-02-2003, 08:27 PM   PM User | #5
Choopernickel
Regular Coder

 
Join Date: Apr 2003
Location: Atlanta, GA
Posts: 487
Thanks: 0
Thanked 0 Times in 0 Posts
Choopernickel is an unknown quantity at this point
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.
Choopernickel is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:27 AM.


Advertisement
Log in to turn off these ads.