页面用word的形式下载

页面用word的方式下载的方式很多,我值介绍两种方式吧!~!

第一种:这种方式比较简单!~!只需要在jsp页面的<@ page>指令里面添加一个

                contentTeyp="application/msword" 就可以了!~!

第二种:用JavaScript脚本控制也可以!~!相关代码如下:

                <script type="text/javascript">
  function  PrintFile() 
  { 
  var  strResult=window.confirm("确认用Word打印吗?"); 
  if(strResult) 
  { 
  try 
  {  
       tableId.focus();  
       document.execCommand("SelectAll");  
       document.execCommand("Copy");  
       tableId.focus();  
       var  WordApp=new  ActiveXObject("Word.Application");  
       WordApp.Application.Visible=true;  
       var  Doc=WordApp.Documents.Add();  
       Doc.Activate();  
       Doc.Content.Paste();  
       Doc.PrintPreview();  
       WordApp.DisplayAlerts=false;  
       Doc.Close();  
       WordApp.DisplayAlerts=true;  
       WordApp.Quit();  
       }  
      catch(e){}  
      }  
      else  
      {      
       var  hwnd=window.open("");  
       hwnd.document.write(App.innerHTML); 
  } 
     return  false; 
  }
 </script>

 

然后再调用一下这个函数就可以了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值