1、获取滚动条滚动的距离
document.documentElement.scrollTop || document.body.scrollTop
2、获取非行间样式
function getStyle(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr]
}else{
return getComputedStyle(obj,false)[attr]
}
}
3、事件对象
var e = e||event;
4、事件对象中的code值
var code = e.keyCode || e.which
5、阻止浏览器的默认行为
e.preventDefault?e.preventDefault():e.returnValue = false
6、阻止事件冒泡
e.stopPropagation?e.stopPropagation():e.cancelBubble = true;
7、获取事件源
e.target || e.srcElement
JS少数兼容
原文地址:https://www.cnblogs.com/-Los/p/9111850.html