このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

Document: close() メソッド

Deprecated

Avoid using this feature in new projects. The dynamic markup insertion API, which includes document.write(), has "very idiosyncratic behavior" which can be difficult to debug. This feature may be a candidate for removal from web standards or browsers.

Consider using the following features instead: DOM.

Document.close() メソッドは、 Document.open() で開かれた文書への書き込みを終了します。

構文

js
close()

引数

なし。

返値

なし (undefined)。

js
// 書きこむ文書を開きます。
document.open();

// 文書の内容を書き込みます。
document.write("<p>たったひとつの内容。</p>");

// 文書を閉じます。
document.close();

仕様書

仕様書
HTML
# dom-document-close-dev

ブラウザーの互換性