location: toString() メソッド - Web API | MDN

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2016年7月.

toString()Location インターフェイスの文字列化メソッドであり、URL 全体を文字列で返します。これは Location.href の読み取り専用版です。

構文

引数

なし。

返値

このオブジェクトの URL を表す文字列です。

js

// このコードが https://example.com/path?search#hash で実行されていると想像してください
const result = window.location.toString(); // 返値: 'https://example.com/path?search#hash'

仕様書

Specification
HTML
# dom-location-href-dev

ブラウザーの互換性

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.