e = e || window.event是js在事件处理兼容IE和非IE的写法。看下面简单写法,在IE8+或非IE会弹出[object MouseEvent],因此为了兼容获取事件相关句柄,就写成var e = e || window.event。
window.onload = function (e){
var div1 = document.getElementById("div1");
div1.onclick = function(e){
alert(e);//IE6/7/8不支持参数传入e为undefined
}
};