標籤: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