//sys.firefox= ua.match(/firefox/([d.]+)/) || false; //后面没有用到所以注销掉
sys.ie= ua.match(/msies([d.]+)/) || false;
//sys.chrome= ua.match(/chrome/([d.]+)/) || false; //后面没有用到所以注销掉
return sys;
})(),
comStyle=function(obj){
return window.getComputedStyle ? window.getComputedStyle(obj, null) : obj.currentStyle;
},
// elem 当前对象 window or other object
elem= typeof elem === 'string' ? document.getElementById(elem) :
elem === undefined ? window : elem,
isie=/^6.0|7.0|8.0$/.test(sys.ie[1]),//是否IE 浏览器
isie67=/^6.0|7.0$/.test(sys.ie[1]),
db=document.body,
dd=document.documentElement,
_this={};
//对象距离浏览器对0 0点的距离
_this.offset=function(o){
//感谢 糖粒子 告诉我这个方法
//有了这个方法至少省略了 15行代码
return (o?o:elem).getBoundingClientRect();
}
//当前对象可见区域的宽 高 window
_this.inner=function(){
var width,height;
//not window object
if ( elem !== window ) {
var computedStyle=comStyle(elem);
width=elem.offsetWidth;
height=elem.offsetHeight;
//isie=/^6.0|7.0|8.0$/.test(sys.ie[1]),
if( isie ){
width-=parseInt(computedStyle.marginTop) || 0;
height-=parseInt(computedStyle.marginLeft) || 0;
}else{
width-=parseInt(computedStyle.paddingTop) || 0;
height-=parseInt(computedStyle.paddingLeft) || 0;
}
} else{
// window 需要区分浏览器
//isie=/^6.0|7.0|8.0$/.test(sys.ie[1]),
if ( isie ){
width=dd.offsetWidth;
height=dd.offsetHeight;
}else{
//当前elem=window
width=elem.innerWidth;
height=elem.innerHeight;
}
}
// 返回的数据格式{width:a,height:b}
return {'width':width,'height':height};
}
//获取对象滚动条卷去的距离
_this.scroll=function(o){
var _elem = o ? o : elem,top,left;
if( _elem === window){
top=db.scrollTop+dd.scrollTop;
left=db.scrollLeft+dd.scrollLeft;
}else{
top=_elem.scrollTop || 0;
left=_elem.scrollLeft || 0;
}
return { 'top':top , 'left':left };
}
//获取对象距离父节点的 位置
_this.offparent=function(){
return {'top':_this.offset(elem).top - _this.offset(elem.parentNode).top,
'left':_this.offset(elem).left - _this.offset(elem.parentNode).left
};
}
//当前对象的可用高度与宽度
_this.client=function(){
return elem==window ? {'width':db.clientWidth,'height':db.clientHeight} :
{'height':elem.scrollWidth,'height':elem.scrollHeight};
}
//屏幕可用工作区宽度高度
_this.screen=function(){
return {'width':window.screen.availWidth,'height':window.screen.availHeight,}
}
//获取当前鼠标的位置
_this.mouse=function (e){//获取鼠标坐标 请传递evnet参数
var e = window.event || e,
p=(e.pageX || e.pageY)?{ x:e.pageX, y:e.pageY } :
{ x:e.clientX + db.scrollLeft - db.clientLeft, y:e.clientY + db.scrollTop - db.clientTop };










