window.location.pathname
Summary
The path to the current document, relative to the root of the current host.
Property of apis/locationapis/location
Syntax
Note: This property is read-only.
var result = window.location.pathname;
Return Value
Returns an object of type StringString
The path to the current document, relative to the root of the current host.
For example, http://example.org/myyfolder/mypage.html
would return the pathname of /myfoler/mypage.html
.
Examples
// Returns the pathname part of the current window location.
// For this page, for instance, this will return the string '/wiki/apis/location/pathname'.
var pname = window.location.pathname;
Related specifications
- Window Object 1.0
- W3C Working Draft