<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html id=body>
<head>
<title> New Document </title>
</head><body onload="aaa()">
<script language="JavaScript">
function aaa(){
document.open("text/html","replace")
document.write("<html><head><title>New File</title></head>")
document.write("<body>This is a new file</body></html>")
}
</script>
</body></html>

解决方案 »

  1.   

    <htm>
    <head>
    <title> New Document </title>
    <script language=javascript>
    function cc(aa)
    {
      document.body.innerHTML = aa;
    }
    </script>
    </head><body ondblclick="alert('网页的内容:\r\n'+document.body.innerHTML)">
    <input type=text name=txt>请在此文本框里输入新网页的内容<br>
    <input type=button value=ok onclick="cc(document.all.txt.value)">
    在网页空白处双击可以弹出当前页面里的内容!
    </body>
    </html>
      

  2.   

    如果是规范文档.
    下面这个更彻底::document.all.tags('html')[0].innerHTML='your html text'连head都可以换掉
      

  3.   

    document.documentElement.outerHTML
      

  4.   

    document.documentElement.outerHTML
    这个够狠这个也狠:
    document.open("text/html", "replace")
    document.write(
    "<html><head>...</head>"
    +"<body>...</body>"
    +"<html>"
    );
    document.close()
      

  5.   

    绝.只是不知道这个document.open还有什么新的用法没有..有没有可利用的漏洞之类的.