aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/document/open/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/api/document/open/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/ja/web/api/document/open/index.html')
-rw-r--r--files/ja/web/api/document/open/index.html114
1 files changed, 114 insertions, 0 deletions
diff --git a/files/ja/web/api/document/open/index.html b/files/ja/web/api/document/open/index.html
new file mode 100644
index 0000000000..1b9da4d82f
--- /dev/null
+++ b/files/ja/web/api/document/open/index.html
@@ -0,0 +1,114 @@
+---
+title: Document.open()
+slug: Web/API/Document/open
+tags:
+ - API
+ - DOM
+ - Document
+ - Method
+ - Reference
+ - open
+ - メソッド
+translation_of: Web/API/Document/open
+---
+<div>{{APIRef("DOM")}}</div>
+
+<p><strong><code>Document.open()</code></strong> メソッドは、{{domxref("Document.write", "書き込み", "", "1")}}のために文書を開きます。</p>
+
+<p>これはいくらかの副作用を招きます。例を挙げます。</p>
+
+<ul>
+ <li>文書、文書内のノード、文書のウィンドウに現在登録されているイベントリスナーがすべて除去されます。</li>
+ <li>すべての既存のノードが文書から除去されます。</li>
+</ul>
+
+<h2 id="Syntax" name="Syntax">構文</h2>
+
+<pre class="syntaxbox notranslate">document.open();
+</pre>
+
+<h3 id="Parameters" name="Parameters">引数</h3>
+
+<p>なし。</p>
+
+<h3 id="Return_value" name="Return_value">返値</h3>
+
+<p><code>Document</code> オブジェクトインスタンスです。</p>
+
+<h2 id="Example" name="Example">例</h2>
+
+<p>以下の簡単なコードは、文書を開き、その内容をいくつかの異なる HTML の断片に置き換えてから、再び閉じます。</p>
+
+<pre class="brush: js notranslate">document.open();
+document.write("&lt;p&gt;Hello world!&lt;/p&gt;");
+document.write("&lt;p&gt;I am a fish&lt;/p&gt;");
+document.write("&lt;p&gt;The number is 42&lt;/p&gt;");
+document.close();
+</pre>
+
+<h2 id="Notes" name="Notes">注</h2>
+
+<p>ページが読み込まれたあとで {{domxref("document.write()")}} が呼び出されると、自動的に <code>document.open()</code> が呼び出されます。</p>
+
+<p>Firefox や Internet Explorer では何年も前から、すべてのノードの削除に加えて、 JavaScript の変数なども追加で消去していました。今はそうではありません。<span class="comment">document non-spec'ed parameters to document.open</span></p>
+
+<h3 id="Gecko-specific_notes" name="Gecko-specific_notes">Gecko 固有のメモ</h3>
+
+<p>Gecko 1.9 以降、このメソッドは他のプロパティと同一オリジンポリシーが同じになるようになり、文書のオリジンを変更しようとした場合に動作しません。</p>
+
+<p>Gecko 1.9.2 以降、 <code>document.open()</code> は<a href="/docs/Security_check_basics">プリンシパル</a>をスタックからフェッチするのではなく、 URI を使用する文書のプリンシパルを使用します。その結果、 <a class="internal" href="/ja/wrappedJSObject"><code>wrappedJSObject</code></a> を使用しても、 {{domxref("document.write()")}} を{{Glossary("chrome", "クローム")}}からの信頼できない文書に呼び出すことはできません。考え方については<a href="/ja/Security_check_basics">セキュリティチェックの基本</a>を参照してください。</p>
+
+<h2 id="Three-argument_document.open" name="Three-argument_document.open">引数3つの document.open()</h2>
+
+<p>あまり知られていませんが、あまり使われていない引数3つ版の <code>document.open()</code> があり、これは {{domxref("Window.open()")}} のエイリアスです (詳細はそのページを参照してください)。</p>
+
+<p>この呼び出しは、例えば github.com を新しいウィンドウで開き、オープナーは <code>null</code> に設定してみます。</p>
+
+<pre class="brush: js notranslate">document.open('https://www.github.com','', 'noopener=true')</pre>
+
+<h2 id="Two-argument_document.open" name="Two-argument_document.open">引数2つの document.open()</h2>
+
+<p>ブラウザーは以下の形で、引数2つの <code>document.open()</code> に対応してきました。</p>
+
+<pre class="brush: js notranslate">document.open(<var>type</var>, <var>replace</var>)</pre>
+
+<p><code><var>type</var></code> は書き込もうとしているデータの MIME タイプ (<code>text/html</code> など) を指定し、 replace が設定されていれば (すなわち "replace" の文字列)、新しい文書の履歴エントリが書き込まれている文書の現在の履歴エントリを置き換えることを指定していました。</p>
+
+<p>この形式は現在では廃止されています。エラーは発生せず、代わりに <code>document.open()</code> に転送されます (つまり、引数なしで実行した場合と同等です)。 履歴の置換動作は常に行われるようになりました。</p>
+
+<h2 id="Specifications" name="Specifications">仕様書</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">仕様書</th>
+ <th scope="col">状態</th>
+ <th scope="col">備考</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName("HTML WHATWG", "#dom-document-open", "document.open()")}}</td>
+ <td>{{Spec2("HTML WHATWG")}}</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>{{SpecName("DOM2 HTML", "html.html#ID-72161170", "document.open()")}}</td>
+ <td>{{Spec2("DOM2 HTML")}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>
+
+<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div>
+
+<p>{{Compat("api.Document.open")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{domxref("Document")}}</li>
+ <li>{{domxref("Window.open()")}}</li>
+</ul>