function getscrollOffset(){
if(window.pageXoffset){
return{
left:pageXoffset,
top:pageYoffset;
}
}else{
return{
left: document.body.scrollLeft + document.documentElement.scrollLeft,
top:document.body.scrollTop + document.documentElement.scrollTop
}
}
}
获取浏览器窗口的尺寸
function getScrollSize(){
if(document.body.scrollWidth){
return{
width: document.body.scrollwidth,
height: document.body.scrollHeight
}
}else{
return{
width: docuemnt.documentElement.scrollWidth,
height: document.documentElement.scrollHeight
}
}
}
获取元素和属性的宽高
function getStyles(elem,prop){
if(window.getComputedStyle){
if(prop){
return window.getComputedStyle(elem,null)[prop];
}else{
return window.getComputedStyle(elem,null);
}else{
if(prop){
return elem.currentStyle[prop];
}else{
if(prop){return elem.currentStyle[prop];
}else{
return elem.currentStyle
}
}
}
}