js获取浏览器和屏幕宽高等信息(转)
生活随笔
收集整理的這篇文章主要介紹了
js获取浏览器和屏幕宽高等信息(转)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
雖然這些東西msdn 中都可以找到,但是為了方便查詢,還是把網(wǎng)友的總結(jié)放了上來:
網(wǎng)頁可見區(qū)域?qū)?#xff1a; document.body.clientWidth
網(wǎng)頁可見區(qū)域高: document.body.clientHeight
網(wǎng)頁可見區(qū)域?qū)?#xff1a; document.body.offsetWidth??(包括邊線和滾動(dòng)條的寬)
網(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
你的屏幕設(shè)置是??window.screen.colorDepth 位彩色
你的屏幕設(shè)置??window.screen.deviceXDPI (像素/英寸)
關(guān)于document.body.scrollTop一直為0的解決辦法~這個(gè)是個(gè)兼容問題~前面有講過 這里再重新說一下~~
解決辦法~~~
=1=
去掉<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
這樣的web標(biāo)準(zhǔn)語句,因?yàn)榧由虾髸?huì)讓document.body.scrollTop一直為0
=2=
寫成:document.documentElement.scrollTop
網(wǎng)頁可見區(qū)域?qū)?#xff1a; document.body.clientWidth
網(wǎng)頁可見區(qū)域高: document.body.clientHeight
網(wǎng)頁可見區(qū)域?qū)?#xff1a; document.body.offsetWidth??(包括邊線和滾動(dòng)條的寬)
網(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
你的屏幕設(shè)置是??window.screen.colorDepth 位彩色
你的屏幕設(shè)置??window.screen.deviceXDPI (像素/英寸)
關(guān)于document.body.scrollTop一直為0的解決辦法~這個(gè)是個(gè)兼容問題~前面有講過 這里再重新說一下~~
解決辦法~~~
=1=
去掉<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
這樣的web標(biāo)準(zhǔn)語句,因?yàn)榧由虾髸?huì)讓document.body.scrollTop一直為0
=2=
寫成:document.documentElement.scrollTop
轉(zhuǎn)載于:https://www.cnblogs.com/zhangsir/archive/2008/01/10/1033984.html
總結(jié)
以上是生活随笔為你收集整理的js获取浏览器和屏幕宽高等信息(转)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: TCSH编程(2)
- 下一篇: 2017年html5行业报告,云适配发布