JS实现点击下载的小例子

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

JS实现点击下载的小例子

  2020-05-13 我要评论
复制代码 代码如下:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <a   href="a.txt"   id=pic1   onclick="savepic();return false;"   style="cursor:hand">点击下载</a> 
          <script> 
                  function   savepic()
                { 
                  if(document.all.a1==null)
                        { 
                                  objIframe=document.createElement("IFRAME"); 
                                  document.body.insertBefore(objIframe); 
                                  objIframe.outerHTML=   "<iframe   name=a1   style='width:0;hieght:0'   src="+pic1.href+"></iframe>"; 
                                  re=setTimeout("savepic()",1) 
                          } 
                 else
                        { 
                                  clearTimeout(re) 
                                  pic   =   window.open(pic1.href,"a1") 
                                  pic.document.execCommand("SaveAs") 
                                  document.all.a1.removeNode(true) 
                          }
                } 
          </script>

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们