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>
预览
Clear
- 课程推荐
- 课件下载
课件暂不提供下载,工作人员正在整理中,后期请多关注该课程~ 















