//Ys为元素,Sj为事件,Hs为函数,bol选择是true绑定事件,还是false解除事件
//需要提前定义a,b,c,bol
function thing(Ys,Sj,Hs,bol){
var info=navigator.userAgent;
if (info.indexOf('NSIE')!=-1) {
var Sj='on'+Sj;
if (bol==true) {
Ys.attachEvent(Sj,Hs);
} else{
Ys.detachEvent(Sj,Hs);
}
} else{
if (bol==true) {
Ys.addEventListener(Sj,Hs,false);
} else{
Ys.removeEventListener(Sj,Hs,false);
}
}
}
转载于:https://www.cnblogs.com/bluesky1024/p/6296114.html