--- title: Document.defaultView slug: Web/API/Document/defaultView translation_of: Web/API/Document/defaultView ---
{{ApiRef}}

在瀏覽器中,document.defaultView 屬性會指向一個目前 {{Glossary("Browsing_context", "document")}} 所屬的 {{domxref("Window", "window")}} 物件,若無則為 null

語法

var win = document.defaultView;

此為唯讀屬性。

規範

Specification Status Comment
{{SpecName('HTML WHATWG', '#dom-document-defaultview', 'Document.defaultView')}} {{Spec2('HTML WHATWG')}} No change
{{SpecName('HTML5 W3C', 'browsers.html#dom-document-defaultview', 'Document.defaultView')}} {{Spec2('HTML5 W3C')}} Initial definition

瀏覽器相容性

{{CompatibilityTable}}
Feature Firefox (Gecko) Chrome Edge Internet Explorer Edge Opera Safari
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatIE("9.0")}} 0.10 {{CompatVersionUnknown}} {{CompatVersionUnknown}}
Feature Firefox Mobile (Gecko) Android Edge IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}