图老师小编精心整理的用JavaScript保存HTML页面中元素希望大家喜欢,觉得好的亲们记得收藏起来哦!您的支持就是小编更新的动力~
【 tulaoshi.com - Web开发 】
在项目,要实现把页面中的一个Table保存到Excel中,代码如下:
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)Html代码 
html  
  head  
     title保存HTML中的Table到Excel中/title  
  /head  
  body  
     h1保存内容到Excel中/h1  
     table id='content'  
         trtd列1/tdtd列2/td/tr  
         trtd列1/tdtd列2/td/tr  
         trtd列1/tdtd列2/td/tr  
         trtd列1/tdtd列2/td/tr  
         trtd列1/tdtd列2/td/tr  
         trtd列1/tdtd列2/td/tr  
         trtd列1/tdtd列2/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.xsl");   
              history.go(-1);   
      }   
    /script  
  /body  
/html  
来源:http://www.tulaoshi.com/n/20160219/1610616.html
看过《用JavaScript保存HTML页面中元素》的人还看了以下文章 更多>>