首页 > 其他 > 详细

Formatting the event object

时间:2016-01-26 12:34:57      阅读:136      评论:0      收藏:0      [点我收藏+]
尽量将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;
};

Formatting the event object

原文:http://www.cnblogs.com/chuangweili/p/5159698.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!