JavaScript-offset、client、scroll相關(guān)屬性解釋
當(dāng)前位置:點(diǎn)晴教程→知識管理交流
→『 技術(shù)文檔交流 』
簡單解釋
offsetTop 指元素距離上方或上層控件的位置,整型,單位像素。 offsetLeft 指元素距離左方或上層控件的位置,整型,單位像素。 offsetWidth 指元素控件自身的寬度,整型,單位像素。 offsetHeight 指元素控件自身的高度,整型,單位像素。 網(wǎng)頁可見區(qū)域?qū)挘篸ocument.body.clientWidth 網(wǎng)頁可見區(qū)域高:document.body.clientHeight 網(wǎng)頁可見區(qū)域?qū)挘篸ocument.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 這里說說四種瀏覽器對 document.body 的 clientHeight、offsetHeight 和 scrollHeight 的解釋。 這四種瀏覽器分別為IE(Internet Explorer)、NS(Netscape)、Opera、FF(FireFox)。 clientHeight 四種瀏覽器對 clientHeight 的解釋都沒有什么異議,都認(rèn)為是內(nèi)容可視區(qū)域的高度,也就是說頁面瀏覽器中可以看到內(nèi)容的這個(gè)區(qū)域的高度,一般是最后一個(gè)工具條以下到狀態(tài)欄以上的這個(gè)區(qū)域,與頁面內(nèi)容無關(guān)。 offsetHeight IE、Opera 認(rèn)為 offsetHeight = clientHeight + 滾動(dòng)條 + 邊框。 NS、FF 認(rèn)為 offsetHeight 是網(wǎng)頁內(nèi)容實(shí)際高度,可以小于 clientHeight。 scrollHeight IE、Opera 認(rèn)為 scrollHeight 是網(wǎng)頁內(nèi)容實(shí)際高度,可以小于 clientHeight。 NS、FF 認(rèn)為 scrollHeight 是網(wǎng)頁內(nèi)容高度,不過最小值是 clientHeight。 簡單地說 clientHeight 就是透過瀏覽器看內(nèi)容的這個(gè)區(qū)域高度。 NS、FF 認(rèn)為 offsetHeight 和 scrollHeight 都是網(wǎng)頁內(nèi)容高度,只不過當(dāng)網(wǎng)頁內(nèi)容高度小于等于 clientHeight 時(shí),scrollHeight 的值是 clientHeight,而 offsetHeight 可以小于 clientHeight。 IE、Opera 認(rèn)為 offsetHeight 是可視區(qū)域 clientHeight 滾動(dòng)條加邊框。scrollHeight 則是網(wǎng)頁內(nèi)容實(shí)際高度。 同理 clientWidth、offsetWidth 和 scrollWidth 的解釋與上面相同,只是把高度換成寬度即可。 該文章在 2010/8/13 18:49:58 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |