事件对象:当事件发生时,浏览器自动建立该对象,并包含该事件的对象,对象尺寸,鼠标位置。
window.onload=function(e){
console.log(e);
}
得出的对象
当然,这样的写法,IE678会报错,因为没有默认的参数,而是用window.event这个全局值代替
window.onload=function(e){
var e=e || window.event;
alert(e);
}
但是用常用的事件绑定方法以后,发现,IE678也直接能用参数弹出事件对象
var box=document.getElementById("box");
if(box.addEventListener){
box.addEventListener("click",test,false);
}else if(box.attachEvent){
box.attachEvent("onclick",test);
}
function test(e){
alert(e)
}
参考: http://www.cnblogs.com/snandy/archive/2011/03/07/1976317.html