addEventListener function in IE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Hill

    #1

    addEventListener function in IE

    I received an error on the addEventListene r line in this function.

    function load()
    {
    el = document.getEle mentById("t");
    el.addEventList ener("click", l_func, false);
    }

    I am using IE 6.0.

    Does IE use something else?

    Mike
  • Martin Honnen

    #2
    Re: addEventListene r function in IE



    Michael Hill wrote:
    [color=blue]
    > I received an error on the addEventListene r line in this function.
    >
    > function load()
    > {
    > el = document.getEle mentById("t");
    > el.addEventList ener("click", l_func, false);
    > }
    >
    > I am using IE 6.0.
    >
    > Does IE use something else?[/color]

    There is no current IE version supporting addEventListene r which is a
    method defined in the W3C DOM Level 2 Events module which IE doesn't
    support.
    IE 5.5 and IE 6 on Windows support
    el.attachEvent( 'onclick', l_func)
    so the difference is that you need to use 'oneventname' as the first
    argument instead of 'eventname' and that there is only a second argument
    , the function. The event model in IE only supports event bubbling so
    there is no third argument.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    • Michael Hill

      #3
      Re: addEventListene r function in IE

      Martin,

      Yes that works ... just one thing though.

      How do you then stop event propagation or the bubbling from going up
      through the heirarchy?

      Mike

      Martin Honnen wrote:[color=blue]
      >
      > Michael Hill wrote:
      >[color=green]
      > > I received an error on the addEventListene r line in this function.
      > >
      > > function load()
      > > {
      > > el = document.getEle mentById("t");
      > > el.addEventList ener("click", l_func, false);
      > > }
      > >
      > > I am using IE 6.0.
      > >
      > > Does IE use something else?[/color]
      >
      > There is no current IE version supporting addEventListene r which is a
      > method defined in the W3C DOM Level 2 Events module which IE doesn't
      > support.
      > IE 5.5 and IE 6 on Windows support
      > el.attachEvent( 'onclick', l_func)
      > so the difference is that you need to use 'oneventname' as the first
      > argument instead of 'eventname' and that there is only a second argument
      > , the function. The event model in IE only supports event bubbling so
      > there is no third argument.
      >
      > --
      >
      > Martin Honnen
      > http://JavaScript.FAQTs.com/[/color]

      Comment

      • Martin Honnen

        #4
        Re: addEventListene r function in IE



        Michael Hill wrote:
        [color=blue]
        > How do you then stop event propagation or the bubbling from going up
        > through the heirarchy?[/color]

        In IE's event model you need to set
        window.event.ca ncelBubble = true;
        to achieve that, see the documentation at
        http://msdn.microsoft.com/library/de.../obj_event.asp

        --

        Martin Honnen
        http://JavaScript.FAQTs.com/

        Comment

        Working...