Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
DOM event
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Internet Explorer-specific model === Microsoft Internet Explorer prior to version 8 does not follow the W3C model, as its own model was created prior to the ratification of the W3C standard. Internet Explorer 9 follows DOM level 3 events,<ref>{{cite web|url=http://blogs.msdn.com/ie/archive/2010/03/26/dom-level-3-events-support-in-ie9.aspx|title=DOM Level 3 Events support in IE9|access-date=2010-03-28|publisher=[[Microsoft]]|date=March 26, 2010}}</ref> and Internet Explorer 11 deletes its support for Microsoft-specific model.<ref>{{cite web|url=http://msdn.microsoft.com/en-us/library/ie/bg182625(v=vs.85).aspx|title=Compatibility changes in IE11 Preview|access-date=2013-10-05|publisher=[[Microsoft]]|date=September 9, 2013}}</ref> {| class="wikitable" ! Name ! Description ! Argument type ! Argument name |- | rowspan=2 | attachEvent | rowspan=2 | Similar to W3C's addEventListener method. | String | sEvent |- | Pointer | fpNotify |- | rowspan=2 | detachEvent | rowspan=2 | Similar to W3C's removeEventListener method. | String | sEvent |- | Pointer | fpNotify |- |- | rowspan=2 | fireEvent | rowspan=2 | Similar to W3C's dispatchEvent method. | String | sEvent |- | Event | oEventObject |- |} Some useful things to know : * To prevent an event bubbling, developers must set the event's <code>cancelBubble</code> property. * To prevent the default action of the event to be called, developers must set the event's <code>returnValue</code> property. * The '''<code>this</code>''' keyword refers to the global '''<code>window</code>''' object. Again, this model differs from the traditional model in that multiple event handlers can be registered for the same event. However the <code>useCapture</code> option can not be used to specify that the handler should be called in the capture phase. This model is supported by Microsoft [[Internet Explorer]] and [[List of web browsers#Trident-based browsers|Trident based browsers]] (e.g. [[Maxthon]], Avant Browser). ==== A rewrite of the example used in the old Internet Explorer-specific model ==== <syntaxhighlight lang="html"> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Internet Explorer-specific model</title> </head> <body> <h1>Internet Explorer-specific model</h1> <p>Hey Joe!</p> <script> var heyJoe = function () { window.alert("Hey Joe!"); } // Add an event handler document.attachEvent("onclick", heyJoe); // Add another event handler window.attachEvent("onload", heyJoe); // Remove the event handler just added window.detachEvent("onload", heyJoe); </script> </body> </html> </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)