一、DOM中的事件对象
1.获取
var event = event
2.事件目标
event.target
3.阻止事件冒泡
event.stopPropagation();
4.阻止默认行为
event.preventDefault()
二、IE中的事件对象
1.获取
window.event;
2.事件目标
event.srcElement;
3.阻止事件冒泡
event.cancelBubble = true;
4.阻止默认行为
event.returnValue = false;
三、跨浏览器事件对象
var EventUtil = { addHandler: function(element, type, handler){ //省略的代码 }, getEvent: function(event){ return event ? event : window.event; }, getTarget: function(event){ return event.target || event.srcElement; }, preventDefault: function(event){ if (event.preventDefault){ event.preventDefault(); } else { event.returnValue = false; } }, removeHandler: function(element, type, handler){ //省略的代码 }, stopPropagation: function(event){ if (event.stopPropagation){ event.stopPropagation(); } else { event.cancelBubble = true; } } };