DOM

Document.location プロパティ

 編集:2022.09.02 by T.A.

[Edge]読取専用。→

Document の URL に関する情報を持った Location オブジェクトを返します。

これはその URL を変更したり他の URL を読み込んだりするためのメソッドも提供しています。

構文
Document.location

読み取り専用の取得値(Location)オブジェクトですが、DOMString を代入することができます。つまり、Document.location が文字列であるかのように扱うことができます。document.location = 'http://www.example.com'document.location.href = 'http://www.example.com' の別名です。

URL を文字列として受け取るだけであれば、読み取り専用の Document.URL プロパティも利用することができます。

Document が閲覧コンテキスト内にない場合、返値は null となります。


テスト