Definition and Usage of documentURI..
The documentURI property sets or returns the location of a document.
If the document was created by the DocumentImplementation object, or if it is undefined, the return value is null.
Tip: Unlike the document.URL property, the documentURI property can be used on any document types, whereas URL can only be used on HTML documents.
Syntax:
Return the documentURI property: document.documentURI
Set the documentURI property: document.documentURI = locationURI
Definition and Usage of Location href Property..
The href property sets or returns the entire URL of the current page.
Syntax:
Return the href property: location.href
Set the href property: location.href = URL
CODING:The documentURI property sets or returns the location of a document.
If the document was created by the DocumentImplementation object, or if it is undefined, the return value is null.
Tip: Unlike the document.URL property, the documentURI property can be used on any document types, whereas URL can only be used on HTML documents.
Syntax:
Return the documentURI property: document.documentURI
Set the documentURI property: document.documentURI = locationURI
Definition and Usage of Location href Property..
The href property sets or returns the entire URL of the current page.
Syntax:
Return the href property: location.href
Set the href property: location.href = URL
<!DOCTYPE html>
<html>
<body>
<a id="top"></a>
<button onclick="bottom()">Go to Bottom</button>
<p>Click the button to display the location of this document</p>
<p><strong>Note:</strong> Internet Explorer does not support the documentURI property.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<p>text...text</p>
<button onclick="top1()">Go to Top</button>
<a id="bottom"></a>
<script>
function myFunction() {
var x = document.documentURI;
var y = document.URL;
var z = location.href;
document.getElementById("demo").innerHTML = x + "<br>" + y + "<br>" + z;
}
function top1() {
location.href = "#top";
}
function bottom() {
location.href = "#bottom";
}
</script>
</body>
</html>
<html>
<body>
<a id="top"></a>
<button onclick="bottom()">Go to Bottom</button>
<p>Click the button to display the location of this document</p>
<p><strong>Note:</strong> Internet Explorer does not support the documentURI property.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<p>text...text</p>
<button onclick="top1()">Go to Top</button>
<a id="bottom"></a>
<script>
function myFunction() {
var x = document.documentURI;
var y = document.URL;
var z = location.href;
document.getElementById("demo").innerHTML = x + "<br>" + y + "<br>" + z;
}
function top1() {
location.href = "#top";
}
function bottom() {
location.href = "#bottom";
}
</script>
</body>
</html>
Comments
Post a Comment