aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/screen/index.html
blob: 4ca30e88e07fe604f9f82986fa6cc52d3e824093 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
title: Screen
slug: Web/API/Screen
tags:
  - API
  - 参考
  - 接口
translation_of: Web/API/Screen
---
<div>{{APIRef("CSSOM View")}}</div>

<p><code>Screen</code> 接口表示一个屏幕窗口,往往指的是当前正在被渲染的window对象,可以使用 <code>window.screen</code> 获取它。</p>

<p>请注意:由浏览器决定提供屏幕对象,此对象一般通过当前浏览器窗口活动状态动态检测来得到。</p>

<h2 id="Example" name="Example">属性</h2>

<dl>
 <dt>{{domxref("Screen.availTop")}}</dt>
 <dd>Specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.</dd>
 <dt>{{domxref("Screen.availLeft")}}</dt>
 <dd>返回屏幕左边边界的第一个像素点</dd>
 <dt>{{domxref("Screen.availHeight")}}</dt>
 <dd>Specifies the height of the screen, in pixels, minus permanent or semipermanent user interface features displayed by the operating system, such as the Taskbar on Windows.</dd>
 <dt>{{domxref("Screen.availWidth")}}</dt>
 <dd>返回窗口中水平方向可用空间的像素值。</dd>
 <dt>{{domxref("Screen.colorDepth")}}</dt>
 <dd>返回屏幕的色彩深度。</dd>
 <dt>{{domxref("Screen.height")}}</dt>
 <dd>以像素为单位返回屏幕的高度。</dd>
 <dt>{{domxref("Screen.left")}}</dt>
 <dd>返回从最左边界到当前屏幕的像素值。</dd>
 <dt>{{domxref("Screen.orientation")}}</dt>
 <dd>返回当前屏幕的转向。</dd>
 <dt>{{domxref("Screen.pixelDepth")}}</dt>
 <dd>获取屏幕的像素点</dd>
 <dt>{{domxref("Screen.top")}}</dt>
 <dd>返回最上边界到当前屏幕的像素值。</dd>
 <dt>{{domxref("Screen.width")}}</dt>
 <dd>返回屏幕的宽度。</dd>
 <dt>{{domxref("Screen.mozEnabled")}} {{gecko_minversion_inline("12.0")}}</dt>
 <dd>布尔值。如果设置为false讲关闭设备的屏幕。</dd>
 <dt>{{domxref("Screen.mozBrightness")}} {{gecko_minversion_inline("12.0")}}</dt>
 <dd>控制设备屏幕的亮度。期望参数是0-1.0之间的浮点数。</dd>
</dl>

<h3 id="Events_handler">Events handler</h3>

<dl>
 <dt>{{domxref("Screen.onorientationchange")}}</dt>
 <dd>{{event("orientationchange")}} 事件的时间处理器。</dd>
 <dt> </dt>
</dl>

<h2 id="方法">方法</h2>

<dl>
 <dt>{{domxref("Screen.lockOrientation")}}</dt>
 <dd>锁定屏幕转向(仅在全屏或者已安装的APP中生效)</dd>
 <dt>{{domxref("Screen.unlockOrientation")}}</dt>
 <dd>解锁屏幕转向(仅在全屏或者已安装的APP中生效)</dd>
</dl>

<p>方法继承于 {{domxref("EventTarget")}}</p>

<p>{{page("/en-US/docs/Web/API/EventTarget","Methods")}}</p>

<h2 id="Example" name="Example">示例</h2>

<pre class="brush:js">if (screen.pixelDepth &lt; 8) {
  // use low-color version of page
} else {
  // use regular, colorful page
}
</pre>

<h2 id="Specification" name="Specification">标准文档说明</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{ SpecName('CSSOM View', '#the-screen-interface', 'Screen') }}</td>
   <td>{{ Spec2('CSSOM View') }}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<div class="hidden">
<p>The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
</div>

<p>{{Compat("api.Screen")}} </p>