ウィンドウlocation.pathname
例
現在のパスを取得します。
let path x = location.pathname;
定義と使用法
このpathname
プロパティは、URL(ページ)のパス名を設定または返します。
構文
pathnameプロパティを返します。
location.pathname
pathnameプロパティを設定します。
location.pathname = path
プロパティ値
Parameter | Description |
path | The pathname of the URL. |
戻り値
タイプ | 説明 |
文字列 | 現在のパス名。 |
ブラウザのサポート
location.pathname
すべてのブラウザでサポートされています:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |