javascript 獲取頁(yè)面的高度及滾動(dòng)條的位置的代碼
更新時(shí)間:2010年05月06日 21:14:38 作者:
javascript獲取頁(yè)面的高度及滾動(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)文章
pc加載更多功能和移動(dòng)端下拉刷新加載數(shù)據(jù)
這篇文章主要為大家詳細(xì)介紹了pc加載更多功能和移動(dòng)端下拉刷新加載數(shù)據(jù),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11點(diǎn)擊按鈕或鏈接不跳轉(zhuǎn)只刷新頁(yè)面的腳本整理
點(diǎn)擊按鈕或鏈接時(shí)不跳轉(zhuǎn)只刷新頁(yè)面,在某些情況下還是比較實(shí)用的,下面整理些不錯(cuò)的示例,感興趣的朋友可以參考下2013-10-10JS實(shí)現(xiàn)簡(jiǎn)單的二維矩陣乘積運(yùn)算
這篇文章主要介紹了JS實(shí)現(xiàn)簡(jiǎn)單的二維矩陣乘積運(yùn)算方法,涉及JavaScript基于數(shù)組操作實(shí)現(xiàn)矩陣運(yùn)算的功能,需要的朋友可以參考下2016-01-01如何解決attachEvent函數(shù)時(shí),this指向被綁定的元素的問(wèn)題?
如何解決attachEvent函數(shù)時(shí),this指向被綁定的元素的問(wèn)題?...2007-04-04幫你徹底搞懂JS中的prototype、__proto__與constructor(圖解)
這篇文章主要介紹了詳解幫你徹底搞懂JS中的prototype、__proto__與constructor(圖解),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-08-08JS實(shí)現(xiàn)的tab切換并顯示相應(yīng)內(nèi)容模塊功能示例
這篇文章主要介紹了JS實(shí)現(xiàn)的tab切換并顯示相應(yīng)內(nèi)容模塊功能,結(jié)合實(shí)例形式分析了JavaScript基于事件響應(yīng)、元素遍歷實(shí)現(xiàn)頁(yè)面tab切換功能相關(guān)操作技巧,需要的朋友可以參考下2019-08-08