文件:documentURI 屬性

Baseline 已廣泛支援

此功能已成熟,可跨多種裝置和瀏覽器版本工作。它自 ⁨2018 年 4 月⁩ 起已在所有瀏覽器中可用。

documentURIDocument 介面的一個只讀屬性,它返回文件的位置(URI)字串。

字串。

示例

JavaScript

js
document.getElementById("url").textContent = document.documentURI;

HTML

html
<p id="urlText">
  URL:<br />
  <span id="url">URL goes here</span>
</p>

結果

規範

規範
DOM
# ref-for-dom-document-documenturi①

瀏覽器相容性

另見

  • document.URL 屬性返回與此屬性相同的值。