aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/screen/width/index.html
blob: 9a412ccbda5f72871b3c06b75efc8e1876042d23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
---
title: Screen.width
slug: Web/API/Screen/width
translation_of: Web/API/Screen/width
---
<div>
 {{APIRef}}</div>
<h2 id="Summary" name="Summary">概述</h2>
<p>返回屏幕的宽度。</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre class="syntaxbox"><var>lWidth</var> = window.screen.width
</pre>
<h2 id="Example" name="Example">示例</h2>
<pre class="brush:js">// crude way to check that the screen is at 1024x768
if (window.screen.width &gt; 1000) {
  // resolution is below 10 x 7
}
</pre>
<h2 id="Notes" name="Notes">备注</h2>
<p>注意,该属性返回的宽度值不一定就是浏览器窗口可使用的宽度。当有其他小工具占据了屏幕空间时,浏览器有时不能占用小工具(如任务栏)占据的空间。<code>window.screen.width</code> 和 <code>window.screen.availWidth</code> 两者不同。相关属性 {{domxref("window.screen.height")}}</p>
<p>在返回该值时,IE 会考虑缩放设置。只有在缩放比例为 100% 时,IE 才返回真实的屏幕宽度。</p>
<h2 id="规范">规范</h2>
<p>{{dom0}}</p>