Bug 6598

Summary: Should support IE Node methods attachEvent and detachEvents
Product: WebKit Reporter: Anders Carlsson <andersca>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WONTFIX    
Severity: Normal CC: aestes, ahmad.saleem792, annevk, ap, bdakin, ddkilzer, ian, rjiang, rniwa, zalan
Priority: P2 Keywords: InRadar
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   

Comment 1 Justin Haygood 2006-01-20 05:45:07 PST
A shared implementation with the W3C methods is possible.

attatchEvent("onload",functionRef) is 100% equivalent to addEventListener
("load",functionRef,false) for instance
Comment 2 Alexey Proskuryakov 2006-04-22 09:16:24 PDT
Fixing this would fix bug 8534.
Comment 3 Alexey Proskuryakov 2006-05-10 13:40:34 PDT
<http://www.quirksmode.org/blog/archives/2005/08/addevent_consid.html>: "addEventListener and attachEvent should not be considered equal".

This talks about the meaning of "this" keyword; looking at the documentation, the bubbling/canceling traits of similar IE and W3C events are also different.
Comment 4 Anders Carlsson 2006-06-04 09:48:01 PDT
We don't need to implement attachEvent and detachEvent in order to support live.com or start.com since the Mozilla compat layer is used which provides implementations of those functions
Comment 5 Dave Hyatt 2006-06-04 11:33:44 PDT
This is one of those areas I'm nervous about supporting.
Comment 6 Dave Hyatt 2006-06-04 11:34:29 PDT
If we added support for this, there are sites that would take us down the IE event handling code path.  I'd rather wait to see if this is a real-world problem before adding support for it.
Comment 7 Justin Haygood 2007-02-19 20:16:36 PST
Couldn't this take the same approach as the hidden document.all support?

Support it if its used, but not if its tested for directly:

site does window.attachEvent("load",function); // Works

site does if( window.attachEvent ) window.attachEvent("load",function); // Doesn't, since window.attachEvent is "hidden".
Comment 8 Darin Fisher (:fishd, Google) 2007-08-20 19:47:48 PDT
here's a real website (popular in the alexa rankings) that depends on attachEvent:
http://house.vnet.cn

granted, it uses attachEvent to scroll some advertisements as you scroll the page!
Comment 9 Maciej Stachowiak 2007-08-20 21:31:28 PDT
Well noted. Should we have a keyword to mark bugs that affect sites which are popular in the Alexa rankings?

Also, is there any way to quantify the risk of sites giving us the IE-compatibility event handling code path that Hyatt mentioned? I would hope most sites would use addEventListener in preference to attachEvent when both are available, but it's hard to be certain.

As a side note, I believe Opera supports the IE event handling methods.
Comment 10 Alexey Proskuryakov 2007-09-26 07:01:32 PDT
(In reply to comment #9)
> Also, is there any way to quantify the risk of sites giving us the
> IE-compatibility event handling code path that Hyatt mentioned?

It seems that testing for attachEvent is a very common way to detect IE, so it clearly needs to be invisible if implemented. See, for example, <http://dev.rubyonrails.org/ticket/6800>.
Comment 11 David Kilzer (:ddkilzer) 2007-11-24 05:20:50 PST
The left navigation panel of the MSDN site requires attachEvent/detachEvent:

http://msdn2.microsoft.com/en-us/library/ms536694.aspx

Because Firefox implements these DOM methods, the left nav panel works when this page is loaded on it.  See the JavaScript in this file as well:

http://msdn2.microsoft.com/App_scripts/ssmoz.js

Comment 12 Ian 'Hixie' Hickson 2007-11-26 13:05:29 PST
I don't understand the last comment -- Firefox doesn't support attachEvent(), and both Safari and Firefox are given attachEvent proxies in the aforementioned compat layer.
Comment 13 David Kilzer (:ddkilzer) 2007-11-26 13:09:33 PST
(In reply to comment #12)
> I don't understand the last comment -- Firefox doesn't support attachEvent(),
> and both Safari and Firefox are given attachEvent proxies in the aforementioned
> compat layer.

Perhaps the compat layer is not being activated with Safari 3, then.  Sorry...didn't look very deeply into the JavaScript code.

Comment 14 David Kilzer (:ddkilzer) 2007-11-26 13:48:11 PST
(In reply to comment #13)
> (In reply to comment #12)
> > I don't understand the last comment -- Firefox doesn't support attachEvent(),
> > and both Safari and Firefox are given attachEvent proxies in the aforementioned
> > compat layer.
> 
> Perhaps the compat layer is not being activated with Safari 3, then. 
> Sorry...didn't look very deeply into the JavaScript code.

And this would be Bug 13546!
Comment 15 Rui Jiang 2008-01-25 17:12:47 PST
Another example of site using this:
https://personal.bank.ecitic.com:444/js/menu4.js

This is top 7th bank in China. Log in with IE from https://personal.bank.ecitic.com:444 (you need an account though)
Comment 16 Andy Estes 2010-09-28 10:27:20 PDT
<rdar://problem/7867748>
Comment 17 Anne van Kesteren 2010-09-29 02:04:49 PDT
(In reply to comment #9)
> As a side note, I believe Opera supports the IE event handling methods.

We are in the process of removing support for these.
Comment 18 Ahmad Saleem 2022-06-14 15:29:16 PDT
Can this bug be closed since even IE11 dropped the support for "attachEvent" in 2013 (release date) and now IE11 is also getting marked as EOL / EOS tomorrow (based on my timezone).

https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa703974(v=vs.85)
Comment 19 Ryosuke Niwa 2022-06-14 16:41:00 PDT
Yeah, this is "won't fix"