Javascript获取屏幕与页面尺寸
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
??? <title>Untitled Page </title>
? <script type="text/javascript">
function checkValue(){
debug.innerText="網頁可見區域寬:document.body.clientWidth.....:"+document.body.clientWidth+"\n"+
"網頁可見區域高:document.body.clientHeight.....:"+document.body.clientHeight+"\n"+
"網頁可見區域高:document.body.offsetWidth.....:"+document.body.offsetWidth+"\n"+
"網頁可見區域高:document.body.offsetHeight.....:"+document.body.offsetHeight+"\n"+
"網頁正文全文寬:document.body.scrollTop.....:"+document.body.scrollTop+"\n"+
"網頁正文全文高:document.body.scrollLeft.....:"+document.body.scrollLeft+"\n"+
"網頁被卷去的高:window.screenTop.....:"+window.screenTop+"\n"+
"網頁被卷去的左:window.screenLeft.....:"+window.screenLeft+"\n"+
"屏幕分辨率的高:window.screen.height.....:"+window.screen.height+"\n"+
"屏幕分辨率的寬:window.screen.width.....:"+window.screen.width+"\n"+
"屏幕可用工作區高度:window.screen.availHeight.....:"+window.screen.availHeight+"\n"+
"屏幕可用工作區寬度:window.screen.availWidth.....:"+window.screen.availWidth+"\n"
}
</script>
??? <script type="text/javascript">
??? function IsConfirm()
??? {
??????? return window.confirm('確定刪除此記錄嗎?');
??? }
???
??? </script>
??? </head>
??? <body>
??????????? <div>
??????????? <div id="content_a" style="display:none; position:absolute;">
??????????????????????? 這是第一個DIV </div>
??????????????? <input type="button" οnclick="checkValue();" value="尺寸調試">改變窗口的大小點擊按鈕看數值的變化
??????????????????? <div id="debug"> </div>
???????????????
??????????? </div>
??? </body>
</html>
總結
以上是生活随笔為你收集整理的Javascript获取屏幕与页面尺寸的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Lambda and Anonymous
- 下一篇: Java 11 究竟比 8 快了多少?看