diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:17 -0500 |
commit | da78a9e329e272dedb2400b79a3bdeebff387d47 (patch) | |
tree | e6ef8aa7c43556f55ddfe031a01cf0a8fa271bfe /files/ko/web/api/document/location/index.html | |
parent | 1109132f09d75da9a28b649c7677bb6ce07c40c0 (diff) | |
download | translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.gz translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.bz2 translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.zip |
initial commit
Diffstat (limited to 'files/ko/web/api/document/location/index.html')
-rw-r--r-- | files/ko/web/api/document/location/index.html | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/files/ko/web/api/document/location/index.html b/files/ko/web/api/document/location/index.html new file mode 100644 index 0000000000..96c514e4b9 --- /dev/null +++ b/files/ko/web/api/document/location/index.html @@ -0,0 +1,69 @@ +--- +title: Document.location +slug: Web/API/Document/location +tags: + - API + - Document + - HTML DOM + - Property + - Read-only + - Reference +translation_of: Web/API/Document/location +--- +<p>{{APIRef("DOM")}}</p> + +<p>The <strong><code>Document.location</code></strong> read-only property returns a {{domxref("Location")}} object, which contains information about the URL of the document and provides methods for changing that URL and loading another URL.</p> + +<p>Though <code>Document.location</code> is a <em>read-only</em> <code>Location</code> object, you can also assign a {{domxref("DOMString")}} to it. This means that you can work with document.location as if it were a string in most cases: <code>document.location = 'http://www.example.com'</code> is a synonym of <code>document.location.href = 'http://www.example.com'</code>.</p> + +<p>To retrieve just the URL as a string, the read-only {{domxref("document.URL")}} property can also be used.</p> + +<p>If the current document is not in a browsing context, the returned value is <code>null</code>.</p> + +<h2 id="Syntax" name="Syntax">Syntax</h2> + +<pre class="syntaxbox"><em>locationObj</em> = document.location +document.location = 'http://www.mozilla.org' // Equivalent to document.location.href = 'http://www.mozilla.org' +</pre> + +<h2 id="Example" name="Example">Example</h2> + +<pre class="brush: js">dump(document.location); +// Prints a string like +// "http://www.example.com/juicybits.html" to the console +</pre> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('HTML WHATWG', "history.html#the-location-interface", "Document.location")}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>No change from {{SpecName("HTML5 W3C")}}.</td> + </tr> + <tr> + <td>{{SpecName('HTML5 W3C', "browsers.html#the-location-interface", "Document.location")}}</td> + <td>{{Spec2('HTML5 W3C')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + + + +<p>{{Compat("api.Document.location")}}</p> + +<h2 id="See_also">See also</h2> + +<ul> + <li>The interface of the returned value, {{domxref("Location")}}.</li> + <li>A similar information, but attached to the {{Glossary("browsing context")}}, {{domxref("Window.location")}}.</li> +</ul> |