Home >Web Front-end >JS Tutorial >Summary of javascript compatibility in event listening_javascript skills
1. IE uses the attachEvent/detachEvent method to add and remove event listeners; w3c uses the addEventListener/removeEventListener method.
2. IE uses the onevent naming method for its events, while w3c uses the event naming method.
3. The IE event listener uses a global Event object, while w3c passes the event object as a parameter to the listener.
4. In order to avoid triggering the default event behavior, IE requires programmers to set the returnValue attribute value in the Event object to false, while w3c's approach is to execute the preventDefault method.
5, IE does not provide support for the event capture phase.
6. To stop the delivery of events, IE’s approach is to set the cancelBubble of the event object to true, while w3c’s approach is to set and execute the stopPropagation method.
7. IE calls the event listener as an independent function, while in w3c it is called as an object method. This means that the this keyword in the event listener in IE points to something other than The event object is a useless global object (window object).
8. IE has a memory leak problem in using event listeners. In IE browser, if you want to create an event listener for an element and use the element in the listener, the memory space occupied by the listener and related DOM nodes will not be occupied before the user enters other pages. be released.