1. document.open()
- 현재 브라우저에 출력된 HTML 콘텐츠를 지우고 새로운 HTML 페이지 시작. 즉 document 객체에 담긴 DOM 트리를 지우고 새로 시작
2. document.close()
- 현재 브라우저에 출력된 HTML 페이지 완성
- 더 이상 document.write() 할 수 없음
예)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
var win = null;
function showHTML(){
win = window.open("","outWin","width=250,height=150");
}
ta = document.getElementById("srcText");
win.document.open();
win.document.write(ta.value);
win.document.close();
}
</script>
</head>
<body>
<h3>HTML 문서 작성기 만들기</h3><hr>
<textarea id="srcText" rows="10" cols="40"></textarea><br>
<button onclick="showHTML()">HTML 문서 작성</button>
</body>
</html>
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
'화면구현' 카테고리의 다른 글
이벤트 (0) | 2020.03.12 |
---|---|
문서의 동적 구성 (0) | 2020.03.12 |
document.write()와 document.writeln() (0) | 2020.03.12 |
this, document, DOM 객체 찾기 (0) | 2020.03.12 |
HTML DOM(Document Object Model) (0) | 2020.03.11 |