Return the path name of a link:
The result of x will be:
The pathname property sets or returns the path name part of the href attribute value.
Note: In the example above, IE 9 and earlier versions returns "test.htm", while IE 10 and higher, Firefox, Opera, Chrome, and Safari returns "/test.htm".
The pathname property is supported in all major browsers.
Return the pathname property:
Set the pathname property:
Value | Description |
---|---|
path | Specifies the path name of a URL |
Return Value: | A String, representing the path name of the URL |
---|
Change the path name of a link:
JavaScript reference: location.pathname Property