Location hrefProperty
Location Object
Definition and Usage
The href property is a readable and writable string that sets or returns the complete URL of the currently displayed document.
Syntax
location.href
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the href property
Example
Example
Return the complete URL (current page):
<script>
document.write(location.href);
</script>
document.write(location.href);
</script>
The output of the above example:
Try it yourself »
Location Object Other Extensions