課程
/前端開發
/JavaScript
/JavaScript進階篇
我只想知道開發webapp時候如何獲取手機屏幕的寬度和長度,誰告訴我:18518678749
2017-03-20
源自:JavaScript進階篇 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;}其它:網頁可見區域寬:document.body.clientWidth 網頁可見區域高:document.body.clientHeight 網頁可見區域寬:document.body.offsetWidth (包括邊線的寬) 網頁可見區域高:document.body.offsetHeight (包括邊線的寬) 網頁正文全文寬:document.body.scrollWidth 網頁正文全文高:document.body.scrollHeight 網頁被卷去的高:document.body.scrollTop 網頁被卷去的左:document.body.scrollLeft 網頁正文部分上:window.screenTop 網頁正文部分左:window.screenLeft 屏幕分辨率的高:window.screen.height 屏幕分辨率的寬:window.screen.width 屏幕可用工作區高度:window.screen.availHeight 屏幕可用工作區寬度:window.screen.availWidth HTML精確定位:scrollLeft,scrollWidth,clientWidth,offsetWidth scrollHeight: 獲取對象的滾動高度。 scrollLeft:設置或獲取位于對象左邊界和窗口中目前可見內容的最左端之間的距離 scrollTop:設置或獲取位于對象最頂端和窗口中可見內容的最頂端之間的距離 scrollWidth:獲取對象的滾動寬度 offsetHeight:獲取對象相對于版面或由父坐標 offsetParent 屬性指定的父坐標的高度 offsetLeft:獲取對象相對于版面或由 offsetParent 屬性指定的父坐標的計算左側位置 offsetTop:獲取對象相對于版面或由 offsetTop 屬性指定的父坐標的計算頂端位置 event.clientX 相對文檔的水平座標 event.clientY 相對文檔的垂直座標 event.offsetX 相對容器的水平坐標 event.offsetY 相對容器的垂直坐標 document.documentElement.scrollTop 垂直方向滾動的值 event.clientX+document.documentElement.scrollTop 相對文檔的水平座標+垂直方向滾動的量
舉報
本課程從如何插入JS代碼開始,帶您進入網頁動態交互世界
2 回答獲取屏幕分辨率的寬和高
2 回答為何我獲取到的和實際分辨率誤差很大?
2 回答分辨率不對
3 回答為啥和屏幕分辨率一樣?
2 回答如何獲取文檔?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
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;
}
其它:
網頁可見區域寬:document.body.clientWidth
網頁可見區域高:document.body.clientHeight
網頁可見區域寬:document.body.offsetWidth (包括邊線的寬)
網頁可見區域高:document.body.offsetHeight (包括邊線的寬)
網頁正文全文寬:document.body.scrollWidth
網頁正文全文高:document.body.scrollHeight
網頁被卷去的高:document.body.scrollTop
網頁被卷去的左:document.body.scrollLeft
網頁正文部分上:window.screenTop
網頁正文部分左:window.screenLeft
屏幕分辨率的高:window.screen.height
屏幕分辨率的寬:window.screen.width
屏幕可用工作區高度:window.screen.availHeight
屏幕可用工作區寬度:window.screen.availWidth
HTML精確定位:scrollLeft,scrollWidth,clientWidth,offsetWidth
scrollHeight: 獲取對象的滾動高度。
scrollLeft:設置或獲取位于對象左邊界和窗口中目前可見內容的最左端之間的距離
scrollTop:設置或獲取位于對象最頂端和窗口中可見內容的最頂端之間的距離
scrollWidth:獲取對象的滾動寬度
offsetHeight:獲取對象相對于版面或由父坐標 offsetParent 屬性指定的父坐標的高度
offsetLeft:獲取對象相對于版面或由 offsetParent 屬性指定的父坐標的計算左側位置
offsetTop:獲取對象相對于版面或由 offsetTop 屬性指定的父坐標的計算頂端位置
event.clientX 相對文檔的水平座標
event.clientY 相對文檔的垂直座標
event.offsetX 相對容器的水平坐標
event.offsetY 相對容器的垂直坐標
document.documentElement.scrollTop 垂直方向滾動的值
event.clientX+document.documentElement.scrollTop 相對文檔的水平座標+垂直方向滾動的量