在JS中怎樣得到瀏覽器窗口的大小

<script>
function show() {
  
s = "網頁可見區域寬:"+ document.body.clientWidth; 
s += "\r\n網頁可見區域高:"+ document.body.clientHeight; 
s += "\r\n網頁可見區域寬:"+ document.body.offsetWidth +" (包括邊線的寬)"; 
s += "\r\n網頁可見區域高:"+ document.body.offsetHeight +" (包括邊線的寬)"; 
s += "\r\n網頁正文全文寬:"+ document.body.scrollWidth; 
s += "\r\n網頁正文全文高:"+ document.body.scrollHeight; 
s += "\r\n網頁被捲去的高:"+ document.body.scroll ; 
s += "\r\n網頁被捲去的左:"+ document.body.scrollLeft; 
s += "\r\n網頁正文部分上:"+ window.screen ; 
s += "\r\n網頁正文部分左:"+ window.screenLeft; 
s += "\r\n屏幕分辨率的高:"+ window.screen.height; 
s += "\r\n屏幕分辨率的寬:"+ window.screen.width; 
s += "\r\n屏幕可用工作區高度:"+ window.screen.availHeight; 
s += "\r\n屏幕可用工作區寬度:"+ window.screen.availWidth; 
alert(s);

}
</script>
<HTML>
<body>
    <button οnclick=show()> </button>
</body>
</HTML>

本文章轉自[華軟網] 原文鏈接:http://www.huarw.com/program/net/aspnet/200804/1561535_2.html

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章