This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

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