Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] Event handler and A tag

Expand Messages
  • Gopal Venkatesan
    ... It has been replied in quite a few threads and also documented in the YUI Events page[1], nevertheless: YAHOO.util.Event.addListener( id-of-anchor ,
    Message 1 of 2 , Aug 31 9:15 PM
    • 0 Attachment
      On Sat, Sep 01, 2007 at 03:57:14AM -0000, tailuo2002 wrote:
      > Hi,
      >
      > When hooking a HTML A TAG(onclick) to yui event handler, how to
      > prevent the page from jumping to another page ?
      >

      It has been replied in quite a few threads and also documented in the
      YUI Events page[1], nevertheless:

      YAHOO.util.Event.addListener("id-of-anchor", "click", function (ev) {
      // do stuff ...
      YAHOO.util.Event.preventDefault(ev);
      });

      will do the trick.

      There are other methods like stopPropagation, which is documented in the
      API documentation page[2].

      [1] http://developer.yahoo.com/yui/event/
      [2] http://developer.yahoo.com/yui/docs/module_event.html

      --
      Gopal Venkatesan

      http://gopalarathnam.com/weblog/
    Your message has been successfully submitted and would be delivered to recipients shortly.