Window location.pathname属性

定义和用法

pathname 属性设置或返回URL(页面)的路径名。

实例

获取当前路径:

let path x = location.pathname;

亲自试一试

语法

返回pathname属性:

location.pathname

设置pathname属性:

location.pathname = path

属性值

Descrizione
path URL的路径名。

Valore di ritorno

Tipo Descrizione
Stringa Percorso corrente.

Supporto del browser

Tutti i browser supportano location.pathname:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Supporto Supporto Supporto Supporto Supporto Supporto