【代碼備忘】Firefox瀏覽器外掛程式xpi自動從網站下載安裝的代碼

來源:互聯網
上載者:User

標籤:ie外掛程式   Firefox瀏覽器   外掛程式   瀏覽器   html   

歡迎加入我們的QQ群,無論你是否工作,學生,只要有c / vc / c++ 編程經驗,就來吧!158427611 

【代碼備忘】Firefox瀏覽器外掛程式xpi自動從網站下載安裝的代碼


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><meta name="description" content="" /><meta name="keywords" content="" /><title>外掛程式測試</title></HEAD><BODY onload="install_firefox_plugin()" ><object classid="clsid:***" id="ie_ClientLoader" height="1" width="1" codebase="http://***/***.dll#VERSION=3,8,0,5"></object><embed id="noIe_ClientLoader" type="application/npcltloader-plugin" width=300 height=50><br><script type="application/javascript">function install_firefox_plugin()  //安裝方法{  var params = {    "Foo": { URL: "http://localhost/fsmeeting-filefox-plugin.xpi", //外掛程式的伺服器位址             IconURL: "http://localhost/foo.png",                  //外掛程式顯示表徵圖             Hash: "sha1:FDB9F859B3D9AA1ECD170D11089AFA023961C943",//外掛程式的檔案hash值             toString: function () { return this.URL; }    }  };  InstallTrigger.install(params);}</script><script>var pluginObj;if(navigator.userAgent.toLowerCase().indexOf("msie") != -1 || (navigator.userAgent.toLowerCase().indexOf("trident") > -1 && navigator.userAgent.toLowerCase().indexOf("rv:1") > -1)){//alert("IE核心瀏覽器,載入IE外掛程式")pluginObj = document.getElementById('ie_ClientLoader');}else{var swf=navigator.plugins["plugin"]; if(!swf){alert("尚未安裝WEB啟動外掛程式,請下載安裝")}else{alert("非IE核心瀏覽器,載入NPAPI外掛程式")}pluginObj = document.getElementById('noIe_ClientLoader');}function ctrip(){try{pluginObj.Run();//使用外掛程式方法}catch(err){//alert(err);alert("該瀏覽器不支援我們的視頻外掛程式");}}function OnRunState(){//外掛程式回調方法。方法名可能每個都不一樣,自己發揮}</script><br><input type=button value="測試" onclick='ctrip();'></center><br></BODY></HTML>


代碼很簡單,不用解釋。!

還附帶了IE核心外掛程式的方法

IE外掛程式只要對應的寫好object標籤,其他工作交給瀏覽器自己就可以了。很方便。


參考文檔:https://developer.mozilla.org/en-US/docs/Installing_Extensions_and_Themes_From_Web_Pages

歡迎加入我們的QQ群,無論你是否工作,學生,只要有c / vc / c++ 編程經驗,就來吧!158427611 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.