Window location.pathname 属性

定义和用法

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

实例

获取当前路径:

let path x = location.pathname;

亲自试一试

语法

返回 pathname 属性:

location.pathname

设置 pathname 属性:

location.pathname = path

属性值

Beskrivelse
path URL 的路径名。

Returværdi

Type Beskrivelse
Streng Nuværende stinavn.

Browserv understøttelse

Alle browsere understøtter location.pathname

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support