→、
Document に指定のHTMLテキスト文字列を書き込みます。
注: document.write() は文書のストリームに書き込みを行うため、閉じられた(読み込み済みの)文書で document.write() を呼び出すと、自動的に document.open() が呼び出され、文書はクリアされます。
Document | Document。 |
---|---|
markup | 文書に書き込まれる マークアップ テキストの文字列です。 |
<html> <head> <title>書き込み例</title> <script> function newContent() { document.open(); document.write("<h1>新しい内容では、古い内容は削除されます!</h1>"); document.close(); } </script> </head> <body onload="newContent();"> <p>元の文書コンテンツ。</p> </body> </html>
¶以下省く
W=window.open("", "Test"); //ウインドウを開き、名前(window.name)を「Test」とする。 Doc=W.document.open(); //そのウインドウで文書を開く(一応記述)。 Doc.write("<BODY>BODY要素。て<B>す</B>とです。"); Doc.write("コードを分けて記述してもつながります。"); Doc.write("</BODY>"); Doc.close();