【代码备忘】火狐浏览器插件xpi自动从网站下载安装的代码

欢迎加入我们的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 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值