Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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."

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #4
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    ev then el, not the other way around. The event instance is always the first argument.

  • #5
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •