---
title: document.documentURI
slug: Web/API/Document/documentURI
tags:
  - API
  - DOM
  - Document
translation_of: Web/API/Document/documentURI
---
<div>{{ApiRef("DOM")}}</div>

<div>{{domxref("Document")}} 接口的属性 <code><strong>documentURI</strong></code> 以字符串的形式返回文档的位置(location)。</div>

<div> </div>

<div>在最初的DOM3定义中,这个属性是可读/写的。在现代的DOM标准(DOM4)中,它是只读的。</div>

<div> </div>

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

<pre class="syntaxbox"><code>var string = document.documentURI;</code>
</pre>

<h2 id="Notes" name="Notes">备注</h2>

<p>HTML 文档有一个 {{domxref("document.URL")}} 属性返回同样的值。但是不像 <code>URL</code>,<code>documentURI</code> 适用于所有类型的文档。</p>

<h2 id="Specification" name="Specification">规范</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('DOM WHATWG', '#dom-document-documenturi','documentURI')}}</td>
   <td>{{Spec2('DOM WHATWG')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('DOM3 Core', '#Document3-documentURI', 'documentURI')}}</td>
   <td>{{Spec2('DOM3 Core')}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>



<p>{{Compat("api.Document.documentURI")}}</p>