HTML DOM documentURI attribute


HTML DOM documentURI Attributes

Instance

<!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>

Running Instance»

Click the "Run Instance" button to view the online instance


Definition and usage

The documentURI attribute can set or return the location of the document.

If the document was created by a DocumentImplementation object, or if it is undefined, null is returned.


Browser support

QQ截图20161108165429.png

Except Internet Explorer, other browsers support the documentURI attribute.


Syntax

Set the documentURI of the document:

document.documentURI=locationURI

Return documentURI:

document.documentURI

Technical details

##Return value: A string representing the URI of the document. DOM VersionCore Level 3 Document Object



##