当前第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属性详解的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
在javascript中添加注释正确的是什么
深入了解javascript中的object(对象)
javascript中sort()方法怎么用
javascript如何改变背景
javascript删除字符串最后一个字符
javascript怎么删除所有节点
不可错过的从原型到原型链,修炼javascript内功
math.max()不带参数会返回什么?为什么?
javascript如何定义变量
为什么把javascript文件放在html底部
更多相关阅读请进入《javascript》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » JavaScript中innerWidth和innerHeight属性详解