Window location.pathname

Example

Get the current path:

let path x = location.pathname;
Try it Yourself »

Description

The pathname property sets or returns the pathname of a URL (page).


Syntax

Return the pathname property:

location.pathname

Set the pathname property:

location.pathname = path

Property Values

Parameter Description
path The pathname of the URL.

Return Value

Type Description
A stringThe current pathname.

Browser Support

location.pathname is supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.