--- title: window.document slug: Web/API/Window/document translation_of: Web/API/Window/document ---
{{ ApiRef() }}
window.document
返回当前窗口内的文档节点({{domxref("document")}})
doc = window.document
doc
是一个指向{{domxref("document")}}对象的引用<!DOCTYPE html> <html> <head> <title>Hello, World!</title> </head> <body> <script type="text/javascript"> var doc = window.document; alert( doc.title); // 弹出: Hello, World! </script> </body> </html>
Specification | Status | Comment |
---|---|---|
{{SpecName('HTML WHATWG', '#dom-document-2', 'Window.document')}} | {{Spec2('HTML WHATWG')}} | |
{{SpecName('HTML5 W3C', 'browsers.html#dom-document-0', 'Window.document')}} | {{Spec2('HTML5 W3C')}} |
{{Compat("api.Window.document")}}