Hi Francis.

Francis Hemsher:
> I would go this way in one coding block:
> 
> myElement.setAttribute("onclick","myClickFunction()")
> myElement.setAttribute("onmouseover","myMouseOver()")
> myElement.setAttribute("onmouseout","myMouseOut()")
> ...etc.
> 
> To dynamically dump them:
> 
> myElement.removeAttribute("onclick")
> myElement.removeAttribute("onmouseover")
> myElement.removeAttribute("onmouseout")

No, I mean more than one event listener for the same event.

  function doSomething() {
      // ...
  }

  function doSomethingElse() {
      // ...
  }

  myElement.addEventListener
      ("click", doSomething, false);
  myElement.addEventListener
      ("click", doSomethingElse, false);

  // when clicked, doSomething() is called then doSomethingElse() is
  // called

  // ...

  myElement.removeEventListener("click", doSomething, false);

  // now when clicked, only doSomethingElse() is called

> >   - You can add capturing event listeners with addEventListener,
> >     but the onXXX attributes define only non-capturing event 
> listeners.
> 
> 
> Can you show me an example of the above? Believe me, I'm glad to 
> learn new techniques.

  document.documentElement.addEventListener("click", blah, true);

The 'blah' function is now a capturing event listener (because I passed
true as the third argument), which means that it will be called for a
click event on any element in the document (because it has been added to
the root svg element, here) before it actually gets to the target.

If blah was:

  function blah(evt) {
      evt.stopPropagation();
  }

then the click event won't even get to its target.

Have a read about event flow, bubbling and capturing here:

  http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-flow-basic

Cameron

-- 
  e-mail : cam (at) mcc.id.au           icq : 26955922
     web : http://mcc.id.au/            msn : cam-msn (at) aka.mcc.id.au
  office : +61399055779              jabber : heycam (at) jabber.org


-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to