addevent兼容函数 && 阻止默认行为 && 阻止传播

function addEvent(a, b, c, d) {
a.addEventListener ? a.addEventListener(b, c, d) : a.attachEvent("on" + b, c)
}

function removeEvent(a, b, c, d) {
a.removeEventListener ? a.removeEventListener(b, c, d) : a.detachEvent("on" + b, c)
}

第四个参数 shi 布尔值

true:表示函数奖注册为捕获事件处理程序,并在事件不同的调度阶段调用。

event.stopPropagation ? event.stopPropagation() : event.cancelBubble = true;

event.preventDefault ? event.preventDefault() : event.returnValue = false;

function setOpacity (obj,o) {
if (obj.filters) obj.filters.alpha.opacity = Math.round(o);
else obj.style.opacity = o / 100;
}
原文地址:https://www.cnblogs.com/rainbow661314/p/3316219.html