1, Event object
e | | Window. Event//ie
2, take the mouse click coordinates with scroll bar
var top = Document.documentElement.scrollTop | | Document.body.scrollTop; //chorme
var x = top + e.clientx; //visual area coordinates
3, get screen coordinates
E.screenx E.screeny
4, Shiftkey Altkey Ctrlkey
5,onkeydown/onkeyup keycode return ASCII code is case-insensitive
chorom/ie return KeyCode Support case
CharCode return character encoding
7, get the event source
target = E.target | | E.srcelement
Target.tagname
E.type
8, Event Flow
FF first captures and then bubbles
IE bubbling
9, Cancel bubbling
true;
Ten, AddEventListener
1, resolved call two times, will not be overwritten (ie upside down)
Window.addeventlistener (' Load ',function() {
Alert (' LV ');
},false);
Window.addeventlistener (' Load ',function() {
Alert (' miss.lv ');
},false);
FF LV miss.lv
IE miss.lv LV
2, resolve to pass two identical functions, execute only once (ie does not resolve, pass the same two functions)
Window.addeventlistener (' Load ', init,false);
Window.addeventlistener (' Load ', init,false);
this point to window)
Window.attachevent (' Load ',function() {
var box = document.getElementById (' box ');
Box.attachevent (' onclick ',function() {
Alert (this ===window); //true
})
})
function addevent (Obj,type, FN) {
Obj.attachevent (' on 'function() {
Fn.call (obj,arguments);
})
}
addevent (window,' Load ',function() {
var box = document.getElementById (' box ');
addevent (box,' click ',function() {
Alert ( this = = box);
})
})
4, add an additional method that does not overwrite
One by one, move into e.ralatedtarget e.fromelement mouseover
Remove the e.ralatedtarget e.toelement mouseout
12, block default behavior
E.preventdefault ();
false;
false, because return false can only be placed in front, and the back cannot be executed.
13, Roller Events
Non-FF MouseWheel
FF Dommousescroll
function (e) {
var this. getEvent (e);
if (E.wheeldelta) {
return E.wheeldelta;
}Else{
return -e.detail*40;
}
}