<input type=button onclick="a=window.open();a.document.write(tbleID.outerHTML);a.document.execCommand('SaveAs');a.close()">

解决方案 »

  1.   

    net_lover(孟子E章)
    <input type=button onclick="a=window.open();a.document.write(tbleID.outerHTML);a.document.execCommand('SaveAs');a.close()">
    此办法存在很严重的缺陷!!!!!更可靠办法是:
    建缓冲文件 save.html,内容是:
    <script language="JavaScript">
    var content = window.opener.document.body.innerHTML;
    // 或 var content = window.opener.document.getElementById("myTableID").innerHTML;
    document.write(content);
    document.execCommand("SaveAs", false, "myTable.html");
    window.close();
    </script>在 myTableID 表格所在页面“保存”按钮onclick调用window.open("save.html",'buffer','top=60,left=30,location=0,width=100,height=60');
      

  2.   


    对不起,save.html应该是这样的
    <body bgcolor="#FFFFFF" text="#000000" onload="save()">
    <script language="JavaScript">
    function save()
    {
    var content = window.opener.document.body.innerHTML;
    //var content = window.opener.document.getElementById("myTableID").innerHTML;
    document.close();
    document.write(content);
    document.execCommand("SaveAs", false, "myTable.html");
    window.close();
    }
    </script>
    </body>