Latest web development tutorials

HTML DOM 가까이 () 메소드

문서 객체 참조 문서 객체

정의 및 사용

가까운 () 메소드는 브라우저 창을 종료하는 데 사용됩니다.

문법

document.close()


브라우저 지원

Internet ExplorerFirefoxOperaGoogle ChromeSafari

모든 주요 브라우저 가까운 지원 () 메소드


예 1

, 출력 스트림을 열고 텍스트를 추가하고 출력 스트림을 닫을 :

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function createDoc(){
    var doc=document.open("text/html","replace");
    var txt="<!DOCTYPE html><html><body>学习 HTML DOM 很有趣!</body></html>";
    doc.write(txt);
    doc.close();
}
</script>
</head>

<body>
<input type="button" value="新文档" onclick="createDoc()">
</body>
</html>

»시도

예 2

출력 스트림을 엽니 다 (새로운 창이 열립니다 약 : 빈), 텍스트를 추가 한 다음 출력 스트림을 닫습니다

<html>
<body>

<script>
var w=window.open();
w.document.open();
w.document.write("<b>Hello World!</b>");
w.document.close();
</script>

</body>
</html>

»시도


문서 객체 참조 문서 객체