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/domain/index.html | 91 +++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 files/ja/web/api/document/domain/index.html (limited to 'files/ja/web/api/document/domain') diff --git a/files/ja/web/api/document/domain/index.html b/files/ja/web/api/document/domain/index.html new file mode 100644 index 0000000000..1e5ac86be5 --- /dev/null +++ b/files/ja/web/api/document/domain/index.html @@ -0,0 +1,91 @@ +--- +title: Document.domain +slug: Web/API/Document/domain +tags: + - API + - Document + - HTML DOM + - Property + - Reference +translation_of: Web/API/Document/domain +--- +
{{ApiRef}}
+ +

{{domxref("Document")}} インターフェイスの domain プロパティは、同一オリジンポリシーで使用される現在の文書の{{glossary("origin", "オリジン")}}のうち、ドメインの部分を取得または設定します。

+ +

このプロパティが正常に設定されると、オリジンのポート番号の部分も {{jsxref("null")}} に設定されます。

+ +

構文

+ +
const domainString = document.domain
+document.domain = domainString
+ +

+ +

現在の文書のオリジンのうち、ドメインの部分です。

+ +

例外

+ +
+
SecurityError
+
以下の状況のうちの一つで、 domain を設定することが試みられた。 +
    +
  • 文書がサンドボックス化された {{htmlelement("iframe")}} の中にある場合
  • +
  • 文書に{{glossary("browsing context", "閲覧コンテキスト")}}がない場合
  • +
  • 文書の影響ドメインnull の場合
  • +
  • 指定された値が文書の影響ドメインと一致しない (または登録可能なドメインの接頭辞ではない) 場合
  • +
  • {{HTTPHeader("Feature-Policy")}} の {{httpheader('Feature-Policy/document-domain','document-domain')}} が有効の場合
  • +
+
+
+ +

+ +

ドメイン名の取得

+ +

http://developer.mozilla.org/en-US/docs/Web の URI において、この例は currentDomain に "developer.mozilla.org" の文字列を設定します。

+ +
const currentDomain = document.domain;
+ +

ウィンドウを閉じる

+ +

文書が www.example.xxx/good.html のような "www.example.xxx" のドメインを持つ場合、この例はウィンドウを閉じようとします。

+ +
const badDomain = "www.example.xxx";
+
+if (document.domain === badDomain) {
+  // 単なる例: window.close() は効果がないことがある
+  window.close();
+}
+
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG','origin.html#relaxing-the-same-origin-restriction','Document.domain')}}{{Spec2('HTML WHATWG')}}
+ +

ブラウザーの互換性

+ + + +
{{Compat("api.Document.domain")}}
+ +

関連情報

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