//所有浏览器都可以用的dom方法
//添加
function on(element, type, callback){
if(element.addEventListener){
element.addEventListener(type,callback,false);
}else if(element.attachEvent){
element.attachEvent("on"+type,callback);
}else{
element["on"+type] = callback;
}
}
//移除
function off(element, type, callback){
if(element.removeEventListener){
return element.removeEventListener(type, callback,false);
}else if(element.detachEvent){
return element.detachEvent("on"+type, callback);
}else{
return element["on"+type] = null;
}
}