document.documentElement.scrollTop || document.body.scrollTop
document.documentElement.scrollLeft || document.body.scrollLeft
//byClassName
//3.兼容byClassName
function byClassName(obj,className){
if(obj.getElementsByClassName){
return obj.getElementsByClassName(className);
}else{
var arr = [];
var ele = obj.getElementsByTagName('*');
for(var i = 0,len = ele.length;i < len;i ++){
if(ele[i].className == className){
arr.push(ele[i]);
}
}
return arr;
}
}
//getAttribute('class') ie8以下 返回null
//oDiv.getAttribute('className') : 除ie8以下支持,其它都返回null
var className = oDiv.getAttribute('className') ? oDiv.getAttribute('className') : oDiv.getAttribute('class');
function getStyle(obj,attr){
return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj,1)[attr];
}
var e = 形参 || window.event;
function getButton(evt){
// evt = evt || window.event;
var e = evt || window.event;
if(evt){
return e.button;
}else if(window.event){
switch(e.button){
case 1 : return 0;
case 4 : return 1;
case 2 : return 2;
}
}
}
event.keyCode || event.which || event.charCode
e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true;
e.preventDefault ? e.preventDefault() : e.returnValue = false;
function addEventListen(obj,evt,fun,boo){
if(obj.attachEvent){
obj.attachEvent('on' + evt,fun);
}else{
obj.addEventListener(evt,fun,boo);
}
}
function removeEventListen(obj,evt,fn,boo){
if(obj.removeEventListener){
obj.removeEventListener(evt,fn,boo);
}else{
obj.detachEvent('on' + evt,fn);
}
}
var target = e.target || e.srcElement;