window.innerHeight window.outerHeight 與screen.height
標簽:
JavaScript
window与screen
window是浏览器支持的全局变量,也可以通过document.defaultView获取它,表示浏览器的窗口信息。
innerHeight与outerHeight
innerHeight表示窗口内容区域的高度,这是不包括边框、菜单栏的。
而outerHeight是窗口的整体高度,包括边框、菜单栏等。
所以一般常用的是innerHeight。
screen.height
screen是指的屏幕,表示当前整个显示器显示的屏幕部分,不限于当前的窗口。height是屏幕的宽度,例如屏幕分辨率1920*1080的话,一般情况下screen.heigth即为1080。
实例
注意width相关的用法是一致的。
看下面的例子:
<html>
<head>
<title></title>
</head>
<body>
<script>
document.writeln("innerHeight:"+window.innerHeight);
document.writeln("innerWidth:"+window.innerWidth);
document.writeln("outerHeight:"+window.outerHeight);
document.writeln("outerWidth:"+window.outerWidth);
document.writeln("screen.height"+window.screen.height);
document.writeln("screen.width"+window.screen.width);
</script>
</body>
</html>
效果如下:
點擊查看更多內容
為 TA 點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦