From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/document/width/index.html | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 files/zh-cn/web/api/document/width/index.html (limited to 'files/zh-cn/web/api/document/width/index.html') 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 +--- +
+ {{ApiRef}} {{Obsolete_header}}
+
+

{{gecko_callout_heading("6.0")}}

+

从Gecko 6.0开始,不再支持document.width,请使用document.body.clientWidth来代替.查看{{domxref("element.clientWidth")}}.

+
+

概述

+

返回当前文档中的{{HTMLElement("body")}}元素的宽度,单位为像素.Internet Explorer不支持该属性.

+

语法

+
pixels = document.width;
+
+

示例

+
function init() {
+    alert("当前文档的宽度为 " + document.width + " 像素.");
+}
+
+

请使用下面的属性来替代该属性

+
document.body.clientWidth              /* <body>元素的宽度 */
+document.documentElement.clientWidth   /* <html>元素的宽度 */
+window.innerWidth                      /* window的宽度 */
+
+

规范

+

{{DOM0}}

+

相关链接

+ -- cgit v1.2.3-54-g00ecf