Location pathnameProperty
Location Object
Definition and Usage
The pathname property is a readable and writable string that can set or return the path part of the current URL.
Syntax
location.pathname
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the pathname property.
Example
Example
Return the pathname of the current URL:
<script>
document.write(location.pathname);
</script>
document.write(location.pathname);
</script>
Output of the above example:
Try it Yourself »
Location Object Other Extensions