<table width="100" border="1" id="tbl">
  <tr>
    <td>111</td>
  </tr>
  <tr>
    <td>222</td>
  </tr>
  <tr>
    <td>3333</td>
  </tr>
  <tr>
    <td>4444</td>
  </tr>
  <tr>
    <td>5555</td>
  </tr>
</table>
<script language="javascript">
function getcontent()
{
document.write(document.getElementById("tbl").innerText);
}
</script>
<input type="button" value="获取" onclick="getcontent()" />

解决方案 »

  1.   

    给你写了一个,我测试过可以的:
    http://www.huoho.com/search/ 的结果存档也是这样实现,原理是先新建一个空白文档,在把内容写上去,再执行保存命令。
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
     <head>
      <title> New Document </title>
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
     </head> <body>
    头部内容<div id="content">试题内容</div><button onclick="CmdSave();">保存试题</button>页底内容  <script language="JavaScript">
      <!--
    function CmdSave()
    {
      var OW = window.open('','','');
      var DD = new Date();
      OW.document.open();
      OW.document.write(document.getElementById("content").innerHTML);
      OW.document.execCommand ("SaveAs",true,"试题存档-"+ DD.getYear() + "-" + DD.getMonth() + "-" + DD.getDate() + "-" + DD.getHours() + "-" + DD.getMinutes() +".htm");
      OW.close();
    }
      //-->
      </script>
     </body>
    </html>
      

  2.   

    TitleRe
    ===========关于使用脚本的html文件内容保存
      

  3.   

    创建一个iframe或者其他窗口或框架
    吧向要的内容写进去
    然后保存那个iframe