CodeWeblog.com » lt,script language,href javascript » Save the page with js content specified. Specified file type

Save the page with js content specified. Specified file type



Save the page with the specified content js



Transfer from: http://rorchina.javaeye.com/blog/184425



<script language=javascript>   

function Save(){   
    var txt = document.all.output.value;
    b = window.open();  
    b.document.open();  
    b.document.write(txt);  
    b.document.close();
    b.document.execCommand('saveas',true,'output.html');
    b.window.close();
}

</script>
 


<center>仅保存文本框中部分:</center>
<table width="90%" align="center" border="0" cellpadding="0" cellspacing="0"> 
    <tr> 
		<td>不保存</td> 
		<td><input type="button" value="Save">

		<textarea rows="20" cols="50"></textarea>
		</td> 
    </tr> 
</table>





Saved in HTML in the Table to Excel



Transfer from: http://www.bcbbs.net/news/Content28841.aspx



<html> 
  <head> 
     <title>保存HTML中的Table到Excel中</title> 
  </head> 
  <body> 
     <h1>保存内容到Excel中</h1> 
     <table> 
         <tr><td>列1</td><td>列2</td></tr> 
         <tr><td>a1</td><td>a2</td></tr> 
         <tr><td>b1</td><td>b2</td></tr> 
         <tr><td>c1</td><td>c2</td></tr> 
         <tr><td>d1</td><td>d2</td></tr> 
         <tr><td>e1</td><td>e2</td></tr> 
         <tr><td>f1</td><td>f2</td></tr> 
     </table> 
      <a href="javascript:downloadfile('content')">保存文件</a> 
    <script language="javascript"> 
       function downloadfile(id)  
      {  
              window.document.write(document.getElementById(id).outerHTML);  
              window.document.execCommand("SaveAs",false,"C:\\download.xls");  
              history.go(-1);  
      }  
    </script> 
  </body> 
</html>  

































Digg Technorati StumbleUpon Mixx del.icio.us Reddit BlinkList Furl YahooMyWeb feedburner

Tags: lt (RSS), script language (RSS), href javascript (RSS), language javascript (RSS), input type (RSS), type button (RSS), cols (RSS), document write (RSS), center border (RSS), cellspacing (RSS), h1 (RSS), c1 (RSS), b1 (RSS), textarea rows (RSS), true output (RSS), output html (RSS), e2 (RSS), f2 (RSS), d1 (RSS), b2 (RSS)

Permalink: http://www.codeweblog.com/save-the-page-with-js-content-specified-specified-file-type/

1 comments to “Save the page with js content specified. Specified file type”

  1. WP Themes on 2010-01-31 09:44:10 :
    Good post and this mail helped me alot in my college assignement. Gratefulness you as your information.

Leave a reply