HTML DOM close() ·½·¨
¶¨ÒåºÍÓ÷¨
close() ·½·¨¿É¹Ø±ÕÒ»¸öÓÉ document.open ·½·¨´ò¿ªµÄÊä³öÁ÷£¬²¢ÏÔʾѡ¶¨µÄÊý¾Ý¡£
Óï·¨
document.close()
˵Ã÷
¸Ã·½·¨½«¹Ø±Õ open() ·½·¨´ò¿ªµÄÎĵµÁ÷£¬²¢Ç¿ÖƵØÏÔʾ³öËùÓлº´æµÄÊä³öÄÚÈÝ¡£Èç¹ûÄúʹÓà write() ·½·¨¶¯Ì¬µØÊä³öÒ»¸öÎĵµ£¬±ØÐë¼Çסµ±ÄãÕâô×öµÄʱºòÒªµ÷Óà close() ·½·¨£¬ÒÔÈ·±£ËùÓÐÎĵµÄÚÈݶ¼ÄÜÏÔʾ¡£
Ò»µ©µ÷ÓÃÁË close()£¬¾Í²»Ó¦¸ÃÔٴε÷Óà write()£¬ÒòΪÕâ»áÒþʽµØµ÷Óà open() À´²Á³ýµ±Ç°Îĵµ²¢¿ªÊ¼Ò»¸öеÄÎĵµ¡£
ʵÀý
<html>
<head>
<script type="text/javascript">
function createNewDoc()
{
var newDoc=document.open("text/html","replace");
var txt="<html><body>Learning about the DOM is FUN!</body></html>";
newDoc.write(txt);
newDoc.close()
;
}
</script>
</head>
<body>
<input type="button" value="Write to a new document"
onclick="createNewDoc()">
</body>
</html>