45fan.com - 路饭网

搜索: 您的位置主页 > 网络频道 > 阅读资讯:判断客户端是否安装了指定的ActiveX控件的方法

判断客户端是否安装了指定的ActiveX控件的方法

2016-09-01 14:55:12 来源:www.45fan.com 【

判断客户端是否安装了指定的ActiveX控件的方法

如何判断客户端是否安装了某个插件?最常见的就是使用DHTML Behavior中的两个方法:isComponentInstalled

但是msdn上有这么一句话:Only Microsoft Internet Explorer components are detected by this method. If a component identifier of a third-party component is specified, the method returns false。

为了解决问题,自己花了1个小时写了下面通用的方法,供大家参考:
<HTML>
<HEAD>
<scripttype="text/javascript">
functiondetectPlugin(CLSID,functionName)
{

varpluginDiv=document.createElement("<divid=/"pluginDiv/"style=/"display:none/"></div>")
document.body.insertBefore(pluginDiv);
pluginDiv.innerHTML
='<objectid="objectForDetectPlugin"classid="CLSID:'+CLSID+'"></object>';
try
{
if(eval("objectForDetectPlugin."+functionName)==undefined)
{
pluginDiv.removeNode(
true);//删除pluginDiv及其所有的子元素
returnfalse;
}

else
{
pluginDiv.removeNode(
true);//删除pluginDiv及其所有的子元素
returntrue;
}
}

catch(e)
{

returnfalse;
}
}

functioncheck()
{

if(detectPlugin(document.all.txtCLSID.value,document.all.txtFunctionName.value))
alert('该控件已经安装')

else
alert('该控件未安装');
}

</script>
</HEAD>

<BODY>
CLSID:<INPUTTYPE="text"NAME="txtCLSID"id="txtCLSID"value="22D6F312-B0F6-11D0-94AB-0080C74C7E95">属性或方法:<INPUTTYPE="text"NAME="txtFunctionName"id="txtFunctionName"value="AutoStart">
<br><INPUTTYPE="submit"value="判断"onclick="check();returnfalse;">
<BODY>
</HTML>
 

本文地址:http://www.45fan.com/a/question/70870.html
Tags: 判断 客户端 装了
编辑:路饭网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部