Home  >  Article  >  Web Front-end  >  A small example of JS implementation of click download_javascript skills

A small example of JS implementation of click download_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:29:141289browse
复制代码 代码如下:


 点击下载 
          <script>  <br>                  function   savepic()<br>                {  <br>                  if(document.all.a1==null)<br>                        {  <br>                                  objIframe=document.createElement("IFRAME");  <br>                                  document.body.insertBefore(objIframe);  <br>                                  objIframe.outerHTML=   "<iframe   name=a1   style='width:0;hieght:0'   src=" pic1.href "></iframe>";  <br>                                  re=setTimeout("savepic()",1)  <br>                          }  <br>                 else<br>                        {  <br>                                  clearTimeout(re)  <br>                                  pic   =   window.open(pic1.href,"a1")  <br>                                  pic.document.execCommand("SaveAs")  <br>                                  document.all.a1.removeNode(true)  <br>                          }<br>                }  <br>          </script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn