473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

addEventListener function in IE

I received an error on the addEventListener line in this function.

function load()
{
el = document.getElementById("t");
el.addEventListener("click", l_func, false);
}

I am using IE 6.0.

Does IE use something else?

Mike
Jul 23 '05 #1
3 18837


Michael Hill wrote:
I received an error on the addEventListener line in this function.

function load()
{
el = document.getElementById("t");
el.addEventListener("click", l_func, false);
}

I am using IE 6.0.

Does IE use something else?


There is no current IE version supporting addEventListener 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/

Jul 23 '05 #2
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:

Michael Hill wrote:
I received an error on the addEventListener line in this function.

function load()
{
el = document.getElementById("t");
el.addEventListener("click", l_func, false);
}

I am using IE 6.0.

Does IE use something else?


There is no current IE version supporting addEventListener 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/

Jul 23 '05 #3


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


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

--

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

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: PJ | last post by:
Is it possible to extend the Node object so that the DOM function addEventListener can be used w/ IE? Does anyone have an example of this? Thanks, Paul
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
3
by: Jake Barnes | last post by:
37 Signals has built some awesome software with some features I wish I knew how to imitate. When I'm logged into my page (http://lkrubner.backpackit.com/pub/337271) any item that I mouseOver I'm...
10
by: Janus | last post by:
Hi, Is there a way to pass arguments to the callback function used inside an addEventListener? I see that I can only list the name of the callback function. For eg, I use this: var...
0
by: aolba | last post by:
Hello, I hope I could get some help with this issue, since I give up. It is too much for just me. This script is originally from MX. I have a hard time trying to translate to AS3. Anyway. There...
6
by: Max | last post by:
i have a event bind function like this(though it is not so robust): bind$=function(o,evt,fn,cb){ var aE='attachEvent'; var aEL='addEventListener'; if(!o&&o){ return o(evt,fn,!!cb); } return...
1
by: mebemikeyc | last post by:
With Element.addEventListener, you can easily wire-up several different event handlers on the fly. This works great, but debugging can be difficult if I don't know what exactly is reacting to an...
5
by: marchaos | last post by:
I'm trying to override the native HTMLElement.addEventListener in firefox so that I can do some extra things. I know it's possible to add methods to the HTMLElement prototype and for them to be...
1
by: Andrew Poulos | last post by:
Is there a way to call removeEventListener when you don't know what events may have been added? With something like object.onclick = blah; I could run through every element in the page, search...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.