DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> 用js調用迅雷下載代碼的二種方法
用js調用迅雷下載代碼的二種方法
編輯:關於JavaScript     

方法一:
復制代碼 代碼如下:
html>

</head>

<script type="text/javascript">

//初始化迅雷插件

function InitialActiveXObject()



   var Thunder;

   try

   {

      Thunder = new ActiveXObject("ThunderAgent.Agent") 

   }catch(e)

   {

     try

     {

       Thunder=new ActiveXObject("ThunderServer.webThunder.1");

     }catch(e)

     {

       try

       {

         Thunder = new ActiveXObject("ThunderAgent.Agent.1");

       }catch(e)

       {

         Thunder = null;

       }     

     }   

   }

   return Thunder;

}

//開始下載

function Download(url)

{

   var Thunder = InitialActiveXObject();

         

   if(Thunder == null)

   {

     DownloadDefault(url);

     return;

   } 

   try

   {    

      Thunder.AddTask(url,"","","","",1,1,10);

      Thunder.CommitTasks();    

   }catch(e)

   {

      try

      {

          Thunder.CallAddTask(url,"","",1,"","");     

       }catch(e)

      {

        DownloadDefault(url);

      }      

   }

}

//容錯函數,打開默認浏覽器下載

function DownloadDefault(url)

{

  //alert('打開浏覽器下載.......');

}
</script>

</head>

         

<body>

<input type="button" value="下載" onclick="Download('thunder://QUFodHRwOi8vZnRwY25jLXAyc3AucGNvbmxpbmUuY29tLmNuL3B1Yi9kb3dubG9hZC8yMDEwMTAvOTFhc3Npc3RhbnRfaXBob25lMjYzLmV4ZVpa')" />

</body>

</html>

方法二:
復制代碼 代碼如下:
<html>

<head>

<SCRIPT src="http://www.jb51.net/js/thunderhref.js"></SCRIPT>

</head>

<body>

<a oncontextmenu=ThunderNetwork_SetHref(this) class=aThunder onclick="return OnDownloadClick_Simple(this)" href="thunder://QUFodHRwOi8vZnRwY25jLXAyc3AucGNvbmxpbmUuY29tLmNuL3B1Yi9kb3dubG9hZC8yMDEwMTAvOTFhc3Npc3RhbnRfaXBob25lMjYzLmV4ZVpa" thunderResTitle="迅雷下載" thunderType="04" thunderPid="00008" thunderHref="thunder://QUFodHRwOi8vZnRwY25jLXAyc3AucGNvbmxpbmUuY29tLmNuL3B1Yi9kb3dubG9hZC8yMDEwMTAvOTFhc3Npc3RhbnRfaXBob25lMjYzLmV4ZVpa">迅雷下載</a>

</body>
</html>

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