HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Location pathname Property

Location Object Reference Location Object

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

Internet Explorer Firefox Opera Google Chrome Safari

The pathname property is supported in all major browsers.


Syntax

Return the pathname property:

location.pathname

Set the pathname property:

location.pathname=path

Value Type Description
path String Specifies the pathname of the URL

Return Value

Type Description
String The pathname


Location Object Reference Location Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE