这是第一个:
function addEvent(el, type, fn){
if(el.addEventListener){
el.addEventListener(type, fn, false);
}else{
el[fn] = function(){
fn.call(el, window.event);
}
el.attachEvent('on'+type, el[fn]);
}
}
第二个:
function addEvent(el, type, fn){
if(el.addEventListener){
el.addEventListener(type, fn, false);
}else{
el['e' + fn] = function(){
fn.call(el, window.event);
}
el.attachEvent('on'+type, el['e'+fn]);
}
}
第二个只是添加一个前缀,它有什么用?