如何在Javascript中检测一些Activex?

时间:2010-05-26 05:36:20

标签: javascript

我在这里有一个activex插件: http://reboltutorial.com/plugins/logo-badge/

我尝试将脚本http://forums.devarticles.com/javascript-development-22/detecting-activex-objects-installed-in-ie-11041.html改编为

<script>
//if RPluginIE is not installed
if( !document.RPluginIE){
document.location.href = "Notfound.html"
}
</script>

但它不起作用。

如何检测任何activex?

1 个答案:

答案 0 :(得分:1)

首先,使用适当的方法进行测试

// read more on http://peter.michaux.ca/articles/feature-detection-state-of-the-art-browser-scripting
function isHostMethod(object, property){
    var t = typeof object[property];
    return t == 'function' ||
        (!!(t == 'object' && object[property])) ||
        t == 'unknown';
}

然后你的代码看起来像

if(!isHostMethod(window", "RPluginIE"){
     document.location.href = "Notfound.html";
}

请注意,我们检查的是窗口,而不是文档。