IE中保存textarea中数据为本地文件

  1.   <HTML>  
  2.   <HEAD>  
  3.           <META   content="text/html;charset=gb2312"   http-equiv="Content-Type">  
  4.   </head>  
  5.   <body>  
  6.   <script type="text/javascript">  
  7.   function   saveas()  
  8.   {  
  9.   var   winSave   =   window.open();  
  10.   winSave.document.open   ("text/html","utf-8");  
  11.   winSave.document.write   (document.getElementById("dataarea").value);  
  12.   winSave.document.execCommand   ('SaveAs',true,'test.txt','.txt');  
  13.   winSave.close();  
  14.   }      
  15.   </script>  
  16.   <textarea id="dataarea">
  17.     Test, just a test
  18. </textarea>
  19.   <input   type=button   value="另存为"   onclick="saveas()">
  20. </body>
  21. </html>

你可能感兴趣的:(IE中保存textarea中数据为本地文件)