document.close()是文档输入流关闭,你都把它关闭了,还怎么覆盖啊!

解决方案 »

  1.   

    You   should   not   use   the   write   or   writeln   methods   on   the   current   document   after   the   document   has   finished   loading   unless   you   first   call   the   open   method,   which   clears   the   current   document 's   window   and   erases   all   variables.覆盖是发生在页面加载结束之后
    <html>
    <head>
    <title> Insert   title   here </title>
    <script   type= "text/javascript ">
    function   output(){
        document.writeln("aaaaaaaaaaa");
        document.close();
        document.writeln("xxxxxxxxxxx");
    }
    </script>
    </head>
    <body>
    <input   type= "button"  value="test write" onclick= "output()"/>
    </body>
    </html>
      

  2.   

    同意楼上说法
    另附上window.close()与document.close()的区别
    http://hi.baidu.com/fangkaiming/blog/item/0a724097727b6c6e55fb968c.html
      

  3.   

    怎么可能覆盖呢?
    可定是输出
    xxxxxxxxx
    aaaaaaaaaa 
      

  4.   

    document.close()是关闭全部的文档输入流。所以不会覆盖了。
      

  5.   

    document.close()既然关闭的是全部文档的输入流,那它下面的语句为什么还是执行了!
    不是矛盾吗???????????????
      

  6.   

    在页面装载之前在页面装载完毕之前document.close()是不起作用的
    而装载完以后document.close()会关闭输入流,如果再次执行
    write会重新清空页面开启输入流。你用firebug设置断点的话可以很明显
    的看到页面的变化,若注释掉先输出a____ 然后b____
        document.open();//这个方法好像可有可无
        document.writeln("a___");
        //document.close();    
        document.writeln("b___");
        document.close();
    若不注释掉输出a____ b____
    此外若最后一个close被注释掉则可以但到虽然也输出a____ b____
    但可以看到页面一直没有加载完毕说明他还在等待输入