HTML DOM ใกล้ () วิธีการ
ความหมายและการใช้งาน
ใกล้ () วิธีการที่ใช้ในการปิดหน้าต่างเบราว์เซอร์
ไวยากรณ์
document.close()
สนับสนุนเบราว์เซอร์
เบราว์เซอร์ที่สำคัญทุกการสนับสนุนอย่างใกล้ชิด () วิธีการ
ตัวอย่าง
ตัวอย่างที่ 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>
<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>
<body>
<script>
var w=window.open();
w.document.open();
w.document.write("<b>Hello World!</b>");
w.document.close();
</script>
</body>
</html>
ลอง»
วัตถุเอกสาร