当前第2页 返回上一页
示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <!DOCTYPE html>
<html>
<head>
<meta charset= "UTF-8" >
<title>浏览器内部的宽度和高度</title>
<style>
body{
text-align:center;
}
.gfg {
font-size:40px;
font-weight:bold;
color:green;
}
</style>
</head>
<body>
<div class = "gfg" >PHP中文网</div>
<h2>浏览器窗口</h2>
<p id= "demo" ></p>
<script>
var Width, Height, result;
Width = window.innerWidth || document.documentElement.clientWidth
|| document.body.clientWidth;
Height = window.innerHeight || document.documentElement.clientHeight
|| document.body.clientHeight;
result = document.getElementById( "demo" );
result.innerHTML = "浏览器内部宽度: " + Width +
"<br>浏览器内部高度: " + Height;
</script>
</body>
</html>
|
输出:

相关推荐:《javascript教程》
本篇文章就是关于JavaScript中Window innerWidth和innerHeight属性的相关介绍,希望对需要的朋友有所帮助!
以上就是JavaScript中innerWidth和innerHeight属性详解的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
js proxy 的优势以及使用场景
详解js中的window.location对象(备忘单)
javascript操作dom对象之select(详细解答)
javascript中对象一般由什么组成
html5 canvas实现中奖转盘的实例代码
javascript中this什么意思
java和javascript啥关系
js数组学习之清空全部元素的4种方法(代码详解)
javascript有没有二维数组
javascript如何设置select值
更多相关阅读请进入《javascript》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » JavaScript中innerWidth和innerHeight属性详解