Ie the difference between the flow of events and dom

1. The difference between the event flow 

IE bubbling type using Netscape event type using the captured before capturing events using DOM events after bubbling type
sample:

copy the code code is as follows:

<body>
<div>
<Button> Click here </ Button>
</ div>
</ body>

bubbling event model type: button-> div-> body (IE event stream)

captive event model: body-> div-> button (Netscape event stream)

the DOM event model: body-> div- > button-> button-> div-> body ( after the first capture bubbling)

2. event listener function difference

IE uses:
[Object] .attachEvent ( "name_of_event_handler", fnHandler); // binding function
[Object] .detachEvent ( "name_of_event_handler", fnHandler) ; // bind to remove

DOM used:
[Object] .addEventListener ( "name_of_event", fnHandler, bCapture); // binding function
[Object] .removeEventListener ( "name_of_event" , fnHandler , bCapture);// Remove Binding

bCapture parameter setting the stage for the event bindings, true for the capture phase, false as the bubbling phase.

Standard the DOM:
[Object] .addEventListener ( "Event Name", fnHandler, whether capture)
[Object] .removeEventListener ( "Event Name", fnHandler, whether capture);
1.DOM use to capture the bubble-type event, true to in the acquisition phase processing, false to handle the bubbling phase
2. the event name is not on
the object that triggered the event 3.this point

IE (the lower version 9):
[Object] .attachEvent ( "Event Name", fnHandler);
[Object] .detachEvent ( "Event Name", fnHandler);
1.IE event using bubble type
2. There are on the event name
3.this point window

Difference
1. execution order is not the same,
2. different parameters
3. Event plus without ON
4.this DIRECTION



Guess you like

Origin www.cnblogs.com/cui-ting/p/11080109.html