JavaScript Screen对象保存浏览器屏幕信息。可用于显示屏幕的width宽度,height高度,colorDepth,pixelDepth等。
Screen屏幕对象是window属性,因此可以通过以下方式访问它:
window.screen
要么,
screen
Screen对象有许多属性,可返回浏览器的信息。
编号 | 属性 | 说明 |
---|---|---|
1 | width | 返回屏幕宽度 |
2 | height | 返回屏幕的高度 |
3 | availWidth | 返回可用宽度 |
4 | availHeight | 返回可用高度 |
5 | colorDepth | 返回颜色深度 |
6 | pixelDepth | 返回像素深度。 |
<script> document.writeln("<br/>screen.width: "+screen.width); document.writeln("<br/>screen.height: "+screen.height); document.writeln("<br/>screen.availWidth: "+screen.availWidth); document.writeln("<br/>screen.availHeight: "+screen.availHeight); document.writeln("<br/>screen.colorDepth: "+screen.colorDepth); document.writeln("<br/>screen.pixelDepth: "+screen.pixelDepth); </script>
screen.width: 1366 screen.height: 768 screen.availWidth: 1366 screen.availHeight: 728 screen.colorDepth: 24 screen.pixelDepth: 24
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)