您的位置:首页 > 移动开发 > Objective-C

Formatting the event object

2016-01-26 11:16 489 查看
尽量将IE与DOM函数事件对象不同的性质或方法转成DOM标准

EventUtil.formatEvent = function (oEvent) {

if (isIE && isWin) { //判断IE的方法略
oEvent.charCode = (oEvent.type == “keypress”) ? oEvent.keyCode : 0;
oEvent.eventPhase = 2;
oEvent.isChar = (oEvent.charCode > 0);
oEvent.pageX = oEvent.clientX + document.body.scrollLeft;
oEvent.pageY = oEvent.clientY + document.body.scrollTop;

oEvent.preventDefault = function () {

this.returnValue = false;

};

if (oEvent.type == “mouseout”) {

oEvent.relatedTarget = oEvent.toElement;

} else if (oEvent.type == “mouseover”) {

oEvent.relatedTarget = oEvent.fromElement;

}

oEvent.stopPropagation = function () {

this.cancelBubble = true;

};

oEvent.target = oEvent.srcElement;

oEvent.time = (new Date).getTime();

}

return oEvent;

};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: