JavaScript 参考手册
/ HTML DOM documentURI 属性
HTML DOM documentURI 属性
HTML DOM documentURI 属性
实例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<p id="demo">单击按钮来显示该文档的位置</p>
<button onclick="myFunction()">点我</button>
<script>
function myFunction(){
var x=document.getElementById("demo");
x.innerHTML=document.documentURI;
}
</script>
<p><strong>注意:</strong>Internet Explorer不支持documentURI属性。</p>
</body>
</html>运行实例 »
点击 "运行实例" 按钮查看在线实例
定义和用法
documentURI 属性可设置或返回文档的位置。
如果文档由 DocumentImplementation 对象创建, 或者如果它未定义,则返回 null。
浏览器支持

除了 Internet Explorer 浏览器,其他浏览器都支持 documentURI 属性。
语法
设置文档的 documentURI:
document.documentURI=locationURI
返回 documentURI:
document.documentURI
技术细节
| 返回值: | 字符串, 代表文档的URI。 |
|---|---|
| DOM 版本 | Core Level 3 Document Object |