From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- files/ko/web/api/document/write/index.html | 102 +++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 files/ko/web/api/document/write/index.html (limited to 'files/ko/web/api/document/write') 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 +--- +
{{ ApiRef("DOM") }}
+ +

{{domxref("document.open()")}}에 의해 열린 문서 스팀에 텍스트 스트링을 적는다.

+ +
주: as document.write writes to the document stream, calling document.write on a closed (loaded) document automatically calls document.open, which will clear the document.
+ +

구문

+ +
document.write(markup);
+
+ +

매개변수

+ +
+
markup
+
document 문성에 씌여질 텍스트를 포함하고 있는 스트링.
+
+ +

+ +
<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>
+
+ +

+ +

Writing to a document that has already loaded without calling {{domxref("document.open()")}} will automatically call document.open. 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 h1 element becomes a node in the document.

+ +

If the document.write() call is embedded within an inlined HTML <script> tag, then it will not call document.open(). For example:

+ +
<script>
+  document.write("<h1>Main title</h1>")
+</script>
+
+ +
Note: document.write and document.writeln do not work in XHTML documents (you'll get a "Operation is not supported" [NS_ERROR_DOM_NOT_SUPPORTED_ERR] error in the error console). This happens when opening a local file with the .xhtml file extension or for any document served with an application/xhtml+xml {{Glossary("MIME type")}}. More information is available in the W3C XHTML FAQ.
+ +
Note: document.write in deferred or asynchronous scripts will be ignored, and you'll get a message like "A call to document.write() from an asynchronously-loaded external script was ignored" in the error console.
+ +
Note: In Edge only, calling document.write more than once in an iframe causes the error SCRIPT70: Permission denied.
+ +
Note: Starting in 55, Chrome will not execute <script> elements injected via document.write() in case of an HTTP cache miss for users on a 2G connection.
+ +

사양

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("HTML WHATWG", "#dom-document-write", "document.write(...)")}}{{Spec2("HTML WHATWG")}} 
{{SpecName("DOM2 HTML", "html.html#ID-75233634", "document.write(...)")}}{{Spec2("DOM2 HTML")}} 
+ +

브라우저 호환성

+ + + +

{{Compat("api.Document.write")}}

+ +

See also

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