示例代码:

 

 

 

<input   type=button   value=另存为   onclick="mm1()">  

<iframe   width=0   height=0   frameborder=0   name=hrong   style="display:   none"></iframe>
      <script language="JavaScript">
      //有窗口弹出的下载
     /* function openfile()
       {    
           var a;
           a =window.open("下载文件的URL","_blank", "width=0, height=0");
           a.document.execCommand("SaveAs");    
           a.close();  
      } */
      //无窗口弹出

      function   mm1()  
    {  
          var str="下载文件的URL";    
          window.frames["hrong"].location.href   =   str;  
          sa();  
}  
function   sa()  
{  
        if(window.frames["hrong"].document.readyState!="complete")  
            setTimeout("sa()",   100);  
      else  
          window.frames["hrong"].document.execCommand('SaveAs');  
}  
      </script>

 

相关文章:

  • 2022-01-20
  • 2022-12-23
  • 2022-01-08
  • 2021-12-30
  • 2021-11-01
  • 2021-10-31
  • 2022-12-23
  • 2021-12-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
  • 2022-01-23
相关资源
相似解决方案