THE WORLD'S LARGEST WEB DEVELOPER SITE

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

COLOR PICKER

colorpicker

SHARE THIS PAGE






Search w3schools.com:

Translate w3schools.com: