Event兼容性代码,按照W3C标准兼容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
var
fixEvent = function (e){
e = e || window.event;
if (!e.preventDefault){
e.preventDefault = function (){
event.returnValue = false ;
};
}
if (!e.stopPropagation){
e.stopPropagation = function (){
event.cancelBubble = true ;
};
}
if (e.pageX === undefined && e.pageY === undefined){
var
doc =document.documentElement || document.body;
e.pageX = e.clientX + doc.scrollLeft - doc.clientLeft;
e.pageY = e.clientY + doc.scrollTop - doc.clientTop;
}
if (!e.target){
e.target = e.srcElement;
}
return
e;
};
|