欢迎加入我们的QQ群,无论你是否工作,学生,只要有c / vc / c++ 编程经验,就来吧!158427611
【代码备忘】火狐浏览器插件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