From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/document/location/index.html | 73 +++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 files/ja/web/api/document/location/index.html (limited to 'files/ja/web/api/document/location') diff --git a/files/ja/web/api/document/location/index.html b/files/ja/web/api/document/location/index.html new file mode 100644 index 0000000000..07129f1740 --- /dev/null +++ b/files/ja/web/api/document/location/index.html @@ -0,0 +1,73 @@ +--- +title: Document.location +slug: Web/API/Document/location +tags: + - API + - Document + - HTML DOM + - Property + - Read-only + - Reference + - プロパティ +translation_of: Web/API/Document/location +--- +

{{APIRef("DOM")}}

+ +

Document.location は読み取り専用のプロパティで、この文書の URL に関する情報を持った {{domxref("Location")}} オブジェクトを返します。これはその URL を変更したり他の URL を読み込んだりするためのメソッドも提供しています。

+ +

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

+ +

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

+ +

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

+ +

構文

+ +

s

+ +
locationObj = document.location
+document.location = 'http://www.mozilla.org' // Equivalent to document.location.href = 'http://www.mozilla.org'
+
+ +

+ +
console.log(document.location);
+// Location オブジェクトをコンソールへ表示
+
+ +

仕様書

+ + + + + + + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG', "history.html#the-location-interface", "Document.location")}}{{Spec2('HTML WHATWG')}}{{SpecName("HTML5 W3C")}} から変更なし
{{SpecName('HTML5 W3C', "browsers.html#the-location-interface", "Document.location")}}{{Spec2('HTML5 W3C')}}初回定義
+ +

ブラウザーの互換性

+ + + +

{{Compat("api.Document.location")}}

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf