diff options
Diffstat (limited to 'files/ko/web/api/document/write/index.html')
-rw-r--r-- | files/ko/web/api/document/write/index.html | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/files/ko/web/api/document/write/index.html b/files/ko/web/api/document/write/index.html new file mode 100644 index 0000000000..5320bb2861 --- /dev/null +++ b/files/ko/web/api/document/write/index.html @@ -0,0 +1,102 @@ +--- +title: Document.write() +slug: Web/API/Document/write +translation_of: Web/API/Document/write +--- +<div>{{ ApiRef("DOM") }}</div> + +<p>{{domxref("document.open()")}}에 의해 열린 문서 스팀에 텍스트 스트링을 적는다.</p> + +<div class="note">주: as <code>document.write</code> writes to the document <strong>stream</strong>, calling <code>document.write</code> on a closed (loaded) document automatically calls <code>document.open</code>, <a href="/en-US/docs/Web/API/document.open#Notes">which will clear the document</a>.</div> + +<h2 id="구문">구문</h2> + +<pre class="brush: js">document.write(<em>markup</em>); +</pre> + +<h3 id="매개변수">매개변수</h3> + +<dl> + <dt><code>markup</code></dt> + <dd>document 문성에 씌여질 텍스트를 포함하고 있는 스트링.</dd> +</dl> + +<h3 id="예">예</h3> + +<pre class="brush: html"><html> + +<head> + <title>write example</title> + + <script> + function newContent() { + alert("load new content"); + document.open(); + document.write("<h1>Out with the old - in with the new!</h1>"); + document.close(); + } + </script> +</head> + +<body onload="newContent();"> + <p>Some original document content.</p> +</body> + +</html> +</pre> + +<h2 id="주">주</h2> + +<p>Writing to a document that has already loaded without calling {{domxref("document.open()")}} will automatically call <code>document.open</code>. Once you have finished writing, it is recommended to call {{domxref("document.close()")}} to tell the browser to finish loading the page. The text you write is parsed into the document's structure model. In the example above, the <code>h1</code> element becomes a node in the document.</p> + +<p>If the <code>document.write()</code> call is embedded within an inlined HTML <code><script></code> tag, then it will not call <code>document.open()</code>. For example:</p> + +<pre class="brush: html"><script> + document.write("<h1>Main title</h1>") +</script> +</pre> + +<div class="note"><strong>Note</strong>: <code>document.write</code> and <code>document.writeln</code> <a href="/en-US/docs/Archive/Web/Writing_JavaScript_for_HTML">do not work in XHTML documents</a> (you'll get a "Operation is not supported" [<code>NS_ERROR_DOM_NOT_SUPPORTED_ERR</code>] error in the error console). This happens when opening a local file with the .xhtml file extension or for any document served with an <code>application/xhtml+xml</code> {{Glossary("MIME type")}}. More information is available in the <a class="external" href="http://www.w3.org/MarkUp/2004/xhtml-faq#docwrite">W3C XHTML FAQ</a>.</div> + +<div class="note"><strong>Note</strong>: <code>document.write</code> in <a href="/en-US/docs/Web/HTML/Element/script#attr-defer">deferred</a> or <a href="/en-US/docs/Web/HTML/Element/script#attr-async">asynchronous</a> scripts will be ignored, and you'll get a message like "A call to <code>document.write()</code> from an asynchronously-loaded external script was ignored" in the error console.</div> + +<div class="note"><strong>Note</strong>: In Edge only, calling <code>document.write</code> more than once in an iframe causes the error SCRIPT70: Permission denied.</div> + +<div class="note"><strong>Note</strong>: Starting in 55, Chrome will not execute <code><script></code> elements injected via <code>document.write()</code> in case of an HTTP cache miss for users on a 2G connection.</div> + +<h2 id="사양">사양</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName("HTML WHATWG", "#dom-document-write", "document.write(...)")}}</td> + <td>{{Spec2("HTML WHATWG")}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName("DOM2 HTML", "html.html#ID-75233634", "document.write(...)")}}</td> + <td>{{Spec2("DOM2 HTML")}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="브라우저_호환성">브라우저 호환성</h2> + + + +<p>{{Compat("api.Document.write")}}</p> + +<h2 id="See_also">See also</h2> + +<ul> + <li>{{ domxref("element.innerHTML") }}</li> + <li>{{ domxref("document.createElement()") }}</li> +</ul> |