JavaScript Window Screen

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_31561851/article/details/89062469

window.screen 对象包含有关用户屏幕的信息。

Window Screen

window.screen对象在编写时可以不使用 window 这个前缀。
一些属性:

  1. screen.availWidth - 可用的屏幕宽度
  2. screen.availHeight - 可用的屏幕高度

Window Screen 可用宽度

screen.availWidth 属性返回访问者屏幕的宽度,以像素计,减去界面特性,比如窗口任务栏。
返回屏幕的可用宽度:

<script>
	document.write("可用宽度: " + screen.availWidth);
</script>

Window Screen 可用高度

screen.availHeight 属性返回访问者屏幕的高度,以像素计,减去界面特性,比如窗口任务栏。
返回屏幕的可用高度:

<script>
	document.write("可用高度: " + screen.availHeight);
</script>

Window Screen 属性集合

// 总宽度/高度
document.write(screen.width + "*" + screen.height);

// 可用宽度/高度: 
document.write(screen.availWidth + "*" + screen.availHeight);

// 色彩深度: 
document.write(screen.colorDepth);

// 色彩分辨率: 
document.write(screen.pixelDepth);

猜你喜欢

转载自blog.csdn.net/qq_31561851/article/details/89062469