element.attachEvent
is unsupported
Browser Compatibility Check
Description
The element.attachEvent
method was removed in Internet Explorer 11.
Help
Use the W3 standard addEventListener() instead, using feature detection to support old versions of IE:
if (obj.addEventListener) { // use W3 DOM method if available (Chrome, Firefox, IE9+, Opera 7+) obj.addEventListener('click', myClick, false); } else if (obj.attachEvent) { // fallback for IE8 and earlier obj.attachEvent('onclick', myClick); } else { // fallback to DOM level 0 (only allows single event handler per event for each element) obj.onclick = myClick; }
Applicable standards
Change history
- 6.47 Dec 2022 Removed since IE is discontinued.
- 5.7 Dec 2014 Fixed false positive.
- 5.4 Feb 2014 Added.
This page describes a web site issue detected in HTML documents by SortSite Desktop and OnDemand Suite.
Rule ID: BugIe11ScriptAttachEvent