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>

  • 相关阅读:
    CF1264E Beautiful League 解题报告
    CF1411G No Game No Life 解题报告
    Data structure on Bitcoin
    bitcoin Cryptography
    弹性布局Flex的基本语法
    Linq操作list
    dt某字段赋值
    List 添加数据
    dt 转 json 转实体
    队列
  • 原文地址:https://www.cnblogs.com/ifishing/p/1748663.html
Copyright © 2011-2022 走看看