Javascript教程
JavaScript基础
JavaScript Objects
JavaScript BOM
JavaScript DOM
JavaScript OOP
JavaScript Cookies
JavaScript事件
JavaScript异常
JavaScript常用

screen对象

JavaScript screen对象保存浏览器屏幕的信息。可用于显示屏幕的width,height,colorDepth,pixelDepth等。
导航器对象是window属性,因此可以通过以下方式访问:
window.screen
或者,
screen

JavaScript屏幕对象的属性

屏幕对象有许多属性,可返回浏览器的信息。
属性 说明
width 返回屏幕宽度
height 返回屏幕的高度
availWidth 返回可用宽度
availHeight 返回可用高度
colorDepth 返回颜色深度
pixelDepth 返回像素深度。

JavaScript屏幕对象的示例

让我们看看屏幕对象的不同用法。
<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
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4