JavaScript » Location » pathname

Syntax:
location.pathname

The pathname property is a string portion of a URL specifying how a particular resource can be accessed.

pathname is a property of both the Link and the Location objects and is a string portion of a URL specifying how a particular resource can be accessed. Assuming your current window to be the URL...
 
http://home.newco.com/products/enquiries.htm#local?email=name@otherco.com
 
...you could find out the pathname property as follows:

NOTE:
 
Although the pathname property can be set at any time, it is safer to set the href property to change a location.

Examples

Code:
document.write(location.pathname)
Output:
/products/enquiries.htm
Explanation:

...you could find out the pathname property as follows: