location: toString() メソッド
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
toString()
は Location
インターフェイスの文字列化メソッドであり、URL 全体を文字列で返します。これは Location.href
の読み取り専用版です。
構文
js
toString()
引数
なし。
返値
このオブジェクトの 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 |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
toString |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- User must explicitly enable this feature.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.