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>


Weiter lernen
||
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!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("psIE: ");
document.write(screen.pixelDepth);
</script>
<body>
</body>
</html>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
einreichenCode zurücksetzen
图片放大关闭