Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 982365 of Window.document

  • Revision slug: Web/API/Window/document
  • Revision title: Window.document
  • Revision id: 982365
  • Created:
  • Creator: Delapouite
  • Is current revision? No
  • Comment fix example brush highlighting

Revision Content

{{APIRef}}

Summary

Returns a reference to the document contained in the window.

Note: {{Fx_minversion_inline(3)}} Firefox 3 alters the security for windows' documents so that only the domain from which it was located can access the document. While this may break some existing sites, it's a move made by both Firefox 3 and Internet Explorer 7, and results in improved security.

Syntax

doc = window.document 

Parameters

  • doc is an object reference to a document.

Example

<!DOCTYPE html>
<html>
<head>
   <title>Hello, World!</title>
</head>
<body>

<script type="text/javascript">
   var doc = window.document;
   console.log(doc.title); // Hello, World!
</script>

</body>
</html>

Specification

Revision Source

<div>{{APIRef}}</div>

<h2 id="Summary" name="Summary">Summary</h2>

<p>Returns a reference to the document contained in the window.</p>

<div class="note"><strong>Note:</strong> {{Fx_minversion_inline(3)}} Firefox 3 alters the security for windows' documents so that only the domain from which it was located can access the document. While this may break some existing sites, it's a move made by both Firefox 3 and Internet Explorer 7, and results in improved security.</div>

<h2 id="Syntax" name="Syntax">Syntax</h2>

<pre class="syntaxbox">
<var>doc</var> = window.document 
</pre>

<h3 id="Parameters" name="Parameters">Parameters</h3>

<ul>
 <li><code>doc</code> is an object reference to a <a href="/en-US/docs/DOM/document" title="DOM/document">document</a>.</li>
</ul>

<h2 id="Example" name="Example">Example</h2>

<pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
   &lt;title&gt;Hello, World!&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;script type="text/javascript"&gt;
   var doc = window.document;
   console.log(doc.title); // Hello, World!
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>

<h2 id="Specification" name="Specification">Specification</h2>

<ul>
 <li><a href="https://www.whatwg.org/html/#the-window-object" title="https://www.whatwg.org/html/#the-window-object">HTML</a></li>
</ul>
Revert to this revision