Window location.pathname 属性

定义和用法

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

实例

获取当前路径:

let path x = location.pathname;

亲自试一试

语法

返回 pathname 属性:

location.pathname

设置 pathname 属性:

location.pathname = path

属性值

Beschreibung
path URL 的路径名。

Rückgabewert

Typ Beschreibung
Zeichenkette Aktueller Pfadname.

Browserunterstützung

Alle Browser unterstützen location.pathname:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Unterstützung Unterstützung Unterstützung Unterstützung Unterstützung Unterstützung