Example
Return the path name of the current URL:
var x = location.pathname;
The result of x will be:
Try it Yourself »
Definition and Usage
The pathname property sets or returns the pathname of a URL.
Browser Support
Property | |||||
---|---|---|---|---|---|
pathname | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the pathname property:
location.pathname
Set the pathname property:
location.pathname=path
Property Values
Value | Type | Description |
---|---|---|
path | String | Specifies the pathname of the URL |
Technical Details
Return Value: | A String, representing the pathname |
---|
< Location Object