zoukankan      html  css  js  c++  java
  • 【转】js实现另存为的方法

    示例代码:

    <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>

  • 相关阅读:
    servlet 将输入内容通过拼接页面的方式显示出来
    localstorage和vue结合使用
    vue的通讯与传递props emit (简单的弹框组件)
    jquery插件之选项卡
    详解Cookie纪要
    jsonp
    滚动条样式
    axios基本使用
    IOS安卓常见问题
    简单购物车
  • 原文地址:https://www.cnblogs.com/ifishing/p/1748663.html
Copyright © 2011-2022 走看看