JS 클릭 다운 로드 를 실현 하 는 작은 예


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

좋은 웹페이지 즐겨찾기