X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP 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

Property
pathname Yes Yes Yes Yes Yes


Syntax

Return the pathname property:

location.pathname

Set the pathname property:

location.pathname=path

Property Values

Value Type Description
path String Specifies the pathname of the URL

Technical Details

Return Value: A String, representing 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 HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook