課程
/前端開發(fā)
/JavaScript
/JavaScript進(jìn)階篇
我只想知道開發(fā)webapp時候如何獲取手機(jī)屏幕的寬度和長度,誰告訴我:18518678749
2017-03-20
源自:JavaScript進(jìn)階篇 8-15
正在回答
https://www.zhihu.com/question/24837204
document.documentElement.clientWidth; document.documentElement.clientHeight;
lz有空驗證下知乎的說法對不對
function a(){"屏幕寬高為:"+screen.width+"*"+screen.height;}這個方法是不是只適用于pc端啊,移動端不適用吧
function a(){"屏幕寬高為:"+screen.width+"*"+screen.height;}其它:網(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 HTML精確定位:scrollLeft,scrollWidth,clientWidth,offsetWidth scrollHeight: 獲取對象的滾動高度。 scrollLeft:設(shè)置或獲取位于對象左邊界和窗口中目前可見內(nèi)容的最左端之間的距離 scrollTop:設(shè)置或獲取位于對象最頂端和窗口中可見內(nèi)容的最頂端之間的距離 scrollWidth:獲取對象的滾動寬度 offsetHeight:獲取對象相對于版面或由父坐標(biāo) offsetParent 屬性指定的父坐標(biāo)的高度 offsetLeft:獲取對象相對于版面或由 offsetParent 屬性指定的父坐標(biāo)的計算左側(cè)位置 offsetTop:獲取對象相對于版面或由 offsetTop 屬性指定的父坐標(biāo)的計算頂端位置 event.clientX 相對文檔的水平座標(biāo) event.clientY 相對文檔的垂直座標(biāo) event.offsetX 相對容器的水平坐標(biāo) event.offsetY 相對容器的垂直坐標(biāo) document.documentElement.scrollTop 垂直方向滾動的值 event.clientX+document.documentElement.scrollTop 相對文檔的水平座標(biāo)+垂直方向滾動的量
舉報
本課程從如何插入JS代碼開始,帶您進(jìn)入網(wǎng)頁動態(tài)交互世界
2 回答獲取屏幕分辨率的寬和高
2 回答為何我獲取到的和實(shí)際分辨率誤差很大?
2 回答分辨率不對
3 回答為啥和屏幕分辨率一樣?
2 回答如何獲取文檔?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2017-04-06
https://www.zhihu.com/question/24837204
document.documentElement.clientWidth;
document.documentElement.clientHeight;
lz有空驗證下知乎的說法對不對
2017-03-24
function a(){
"屏幕寬高為:"+screen.width+"*"+screen.height;
}這個方法是不是只適用于pc端啊,移動端不適用吧
2017-03-20
function a(){
"屏幕寬高為:"+screen.width+"*"+screen.height;
}
其它:
網(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
HTML精確定位:scrollLeft,scrollWidth,clientWidth,offsetWidth
scrollHeight: 獲取對象的滾動高度。
scrollLeft:設(shè)置或獲取位于對象左邊界和窗口中目前可見內(nèi)容的最左端之間的距離
scrollTop:設(shè)置或獲取位于對象最頂端和窗口中可見內(nèi)容的最頂端之間的距離
scrollWidth:獲取對象的滾動寬度
offsetHeight:獲取對象相對于版面或由父坐標(biāo) offsetParent 屬性指定的父坐標(biāo)的高度
offsetLeft:獲取對象相對于版面或由 offsetParent 屬性指定的父坐標(biāo)的計算左側(cè)位置
offsetTop:獲取對象相對于版面或由 offsetTop 屬性指定的父坐標(biāo)的計算頂端位置
event.clientX 相對文檔的水平座標(biāo)
event.clientY 相對文檔的垂直座標(biāo)
event.offsetX 相對容器的水平坐標(biāo)
event.offsetY 相對容器的垂直坐標(biāo)
document.documentElement.scrollTop 垂直方向滾動的值
event.clientX+document.documentElement.scrollTop 相對文檔的水平座標(biāo)+垂直方向滾動的量