javascript 获取页面的高度及滚动条的位置的代码
更新时间:2010年05月06日 21:14:38 作者:
javascript获取页面的高度及滚动条的位置的代码,需要的朋友可以参考下。
复制代码 代码如下:
var Viewport={
top : function(){
return window.pageYOffset
|| document.documentElement && document.documentElement.scrollTop
|| document.body.scrollTop;
},
height : function(){
return window.innerHeight
|| document.documentElement && document.documentElement.clientHeight
|| document.body.clientHeight;
},
left : function(){
return window.pageXOffset
|| document.documentElement && document.documentElement.scrollLeft
|| document.body.scrollLeft;
},
width : function(){
return window.innerWidth
|| document.documentElement && document.documentElement.clientWidth
|| document.body.clientWidth;
},
right : function(){
return Viewport.left() + Viewport.width();
},
bottom : function(){
return Viewport.top() + Viewport.height();
}
};
居中:
复制代码 代码如下:
style.position="absolute";
style.left=50%;
style.top=Viewport.Top()+Viewport.Height()/2+"px";
相关文章
Bootstrap分页插件之Bootstrap Paginator实例详解
Bootstrap Paginator是一款基于Bootstrap的js分页插件,功能很丰富,个人觉得这款插件已经无可挑剔了,感兴趣的朋友跟着脚本之家小编一起学习吧2016-10-10
使用UrlConnection实现后台模拟http请求的简单实例
这篇文章主要介绍了使用UrlConnection实现后台模拟http请求的简单实例的相关资料,需要的朋友可以参考下2017-01-01
bootstrap datepicker限定可选时间范围实现方法
这篇文章主要介绍了bootstrap datepicker限定可选时间范围的实现方法,本文涉及到相关知识点,通过实例给大家介绍的非常详细,需要的朋友可以参考下2016-09-09


最新评论