- 相關(guān)推薦
如何使用JavaScript快速獲取頁面高度寬度
如何使用JavaScript快速獲取頁面高度寬度呢?大家可以嘗試一下代碼的實(shí)現(xiàn),更多詳情請(qǐng)關(guān)注應(yīng)屆畢業(yè)生考試網(wǎng)。
/********************
* 取窗口滾動(dòng)條高度
******************/
function getScrollTop()
{
var scrollTop=0;
if(document.documentElement&&document.documentElement.scrollTop)
{
scrollTop=document.documentElement.scrollTop;
}
else if(document.body)
{
scrollTop=document.body.scrollTop;
}
return scrollTop;
}
/********************
* 取窗口可視范圍的高度
*******************/
function getClientHeight()
{
var clientHeight=0;
if(document.body.clientHeight&&document.documentElement.clientHeight)
{
var clientHeight = (document.body.clientHeight<document.documentElement.clientHeight)?docum
ent.body.clientHeight:document.documentElement.clientHeight;
}
else
{
var clientHeight = (document.body.clientHeight>document.documentElement.clientHeight)?docum
ent.body.clientHeight:document.documentElement.clientHeight;
}
return clientHeight;
}
/********************
* 取文檔內(nèi)容實(shí)際高度
*******************/
function getScrollHeight()
{
return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);
}
【如何使用JavaScript快速獲取頁面高度寬度】相關(guān)文章:
如何使用JavaScript實(shí)現(xiàn)頁面定時(shí)跳轉(zhuǎn)10-18
JavaScript如何獲取獲取當(dāng)前年月日星期06-04
JavaScript如何獲取地址欄中傳遞參數(shù)10-06
如何使用firework設(shè)計(jì)網(wǎng)站頁面09-18
如何快速獲取2017年考研信息與資料08-08
如何使用JavaScript實(shí)現(xiàn)倒計(jì)時(shí)10-14