吾爱学编程:好玩有趣的手游网!
当前位置:首页JavaScript 教程 → JavaScript 屏幕对象

JavaScript 屏幕对象

来源:网络 | 更新时间:2022-01-09 09:35:20
JavaScript的screen 对象拥有浏览器屏幕的信息。可用于显示屏幕宽度、高度、颜色深度、像素深度等。 screen 对象是 window 属性,因此可以通过以下方式访问它:
window.screen 
或者,
screen 

JavaScript Screen 对象的属性

返回浏览器信息的屏幕对象有很多属性。
No. 属性 描述
1 width 返回屏幕的宽度
2 height 返回屏幕的高度
3 availWidth 返回可用宽度
4 availHeight 返回可用高度
5 colorDepth 返回颜色深度
6 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 2020-2030吾爱学编程

本站资源收集于网络,如有侵权请联系我们:35492删除0109@qq.com