javascript 獲取頁面的高度及滾動(dòng)條的位置的代碼
更新時(shí)間:2010年05月06日 21:14:38 作者:
javascript獲取頁面的高度及滾動(dòng)條的位置的代碼,需要的朋友可以參考下。
復(fù)制代碼 代碼如下:
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();
}
};
居中:
復(fù)制代碼 代碼如下:
style.position="absolute";
style.left=50%;
style.top=Viewport.Top()+Viewport.Height()/2+"px";
相關(guān)文章
Javascript中數(shù)組sort和reverse用法分析
這篇文章主要介紹了Javascript中數(shù)組sort和reverse用法,實(shí)例分析了sort和reverse使用時(shí)的注意事項(xiàng)與相關(guān)技巧,具有不錯(cuò)的參考借鑒價(jià)值,需要的朋友可以參考下2014-12-12
Bootstrap分頁插件之Bootstrap Paginator實(shí)例詳解
Bootstrap Paginator是一款基于Bootstrap的js分頁插件,功能很豐富,個(gè)人覺得這款插件已經(jīng)無可挑剔了,感興趣的朋友跟著腳本之家小編一起學(xué)習(xí)吧2016-10-10
使用UrlConnection實(shí)現(xiàn)后臺模擬http請求的簡單實(shí)例
這篇文章主要介紹了使用UrlConnection實(shí)現(xiàn)后臺模擬http請求的簡單實(shí)例的相關(guān)資料,需要的朋友可以參考下2017-01-01
bootstrap datepicker限定可選時(shí)間范圍實(shí)現(xiàn)方法
這篇文章主要介紹了bootstrap datepicker限定可選時(shí)間范圍的實(shí)現(xiàn)方法,本文涉及到相關(guān)知識點(diǎn),通過實(shí)例給大家介紹的非常詳細(xì),需要的朋友可以參考下2016-09-09

