【轉(zhuǎn)】關(guān)于top、clientTop、scrollTop、offsetTop等
clientWidth = width - border clientHeight = height - border offsetWidth = width offsetHeight = height
IE,F(xiàn)ireFox 差異如下:
IE6.0、FF1.06+:
clientWidth = width + padding clientHeight = height + padding offsetWidth = width + padding + border offsetHeight = height + padding + border
IE5.0/5.5:
var winWidth = 0;
var winHeight = 0;
function findDimensions() //函數(shù):獲取尺寸
{ //獲取窗口寬度
if (window.innerWidth)
winWidth = window.innerWidth;
else if ((document.body) && (document.body.clientWidth))
winWidth = document.body.clientWidth; //獲取窗口高度
if (window.innerHeight)
winHeight = window.innerHeight;
else if ((document.body) && (document.body.clientHeight))
winHeight = document.body.clientHeight; //通過深入Document內(nèi)部對(duì)body進(jìn)行檢測(cè),獲取窗口大小
if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth)
{
winHeight = document.documentElement.clientHeight;
winWidth = document.documentElement.clientWidth;
} //結(jié)果輸出至兩個(gè)文本框
document.form1.availHeight.value= winHeight;
document.form1.availWidth.value= winWidth;
} findDimensions(); //調(diào)用函數(shù),獲取數(shù)值
window.onresize=findDimensions;
網(wǎng)頁可見區(qū)域?qū)挘?document.body.clientWidth;
網(wǎng)頁可見區(qū)域高: document.body.clientHeight;
網(wǎng)頁可見區(qū)域?qū)挘?document.body.offsetWidth (包括邊線的寬);
網(wǎng)頁可見區(qū)域高: document.body.offsetHeight (包括邊線的寬);
網(wǎng)頁正文全文寬: document.body.scrollWidth;
網(wǎng)頁正文全文高: document.body.scrollHeight;
網(wǎng)頁被卷去的高: document.body.scrollTop;
網(wǎng)頁被卷去的左: document.body.scrollLeft;
網(wǎng)頁正文部分上: window.screenTop;
網(wǎng)頁正文部分左: window.screenLeft;
屏幕分辨率的高: window.screen.height;
屏幕分辨率的寬: window.screen.width;
屏幕可用工作區(qū)高度: window.screen.availHeight;
屏幕可用工作區(qū)寬度:window.screen.availWidth;

作者:山邊小溪
主站:yyyweb.com 記住啦:)
歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處。


浙公網(wǎng)安備 33010602011771號(hào)