diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/document/width/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/document/width/index.html')
-rw-r--r-- | files/zh-cn/web/api/document/width/index.html | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/document/width/index.html b/files/zh-cn/web/api/document/width/index.html new file mode 100644 index 0000000000..47a2d1e13a --- /dev/null +++ b/files/zh-cn/web/api/document/width/index.html @@ -0,0 +1,32 @@ +--- +title: document.width +slug: Web/API/Document/width +translation_of: Web/API/Document/width +--- +<div> + {{ApiRef}} {{Obsolete_header}}</div> +<div class="geckoVersionNote"> + <p>{{gecko_callout_heading("6.0")}}</p> + <p>从Gecko 6.0开始,<code>不再支持document.width,请使用</code><code>document.body.clientWidth</code>来代替.查看{{domxref("element.clientWidth")}}.</p> +</div> +<h2 id="Summary" name="Summary">概述</h2> +<p>返回当前文档中的{{HTMLElement("body")}}元素的宽度,单位为像素.Internet Explorer不支持该属性.</p> +<h2 id="Syntax" name="Syntax">语法</h2> +<pre class="syntaxbox"><em>pixels</em> = document.width; +</pre> +<h2 id="Example" name="Example">示例</h2> +<pre class="brush:js">function init() { + alert("当前文档的宽度为 " + document.width + " 像素."); +} +</pre> +<h2 id="Alternatives" name="Alternatives">请使用下面的属性来替代该属性</h2> +<pre class="syntaxbox">document.body.clientWidth /* <body>元素的宽度 */ +document.documentElement.clientWidth /* <html>元素的宽度 */ +window.innerWidth /* window的宽度 */ +</pre> +<h2 id="Specification" name="Specification">规范</h2> +<p>{{DOM0}}</p> +<h2 id="See_also" name="See_also">相关链接</h2> +<ul> + <li>{{domxref("document.height")}}</li> +</ul> |