DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> JavaScript綜合知識 >> JS實現點擊下載的小例子
JS實現點擊下載的小例子
編輯:JavaScript綜合知識     
這篇文章介紹了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>

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved