screen对象

screen

screen对象表示屏幕的信息,常用的属性有:

screen.width:屏幕宽度,以像素为单位;

screen.height:屏幕高度,以像素为单位;

screen.colorDepth:返回颜色位数,如8、16、24。

<html>
<head>
    <script>
        'use strict';
        alert('Screen size = ' + screen.width + ' x ' + screen.height);
    </script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<script>
document.write("可用高度:" + screen.availHeight);
</script>
</body>
</html>


继续学习
||
<!DOCTYPE html> <html> <body> <h3>Your Screen:</h3> <script> document.write("窗口可以使用的屏幕宽高: "); document.write(window.screen.availWidth + "*" + screen.availHeight); document.write("<br>"); document.write("屏幕的宽高: "); document.write(screen.availWidth + "*" + window.screen.height); document.write("<br>"); document.write("用户浏览器表示的颜色位数: "); document.write(window.screen.colorDepth); document.write("<br>"); document.write("用户浏览器表示的颜色位数(ps:IE不支持?亲测好像支持唉): "); document.write(screen.pixelDepth); </script> <body> </body> </html>
提交重置代码
章节
笔记
提问
课件
反馈
捐赠

弹指间学会JavaScript 教程