简体   繁体   English

如何在JavaScript中检测一些Activex?

[英]How to detect some Activex in Javascript?

I have an activex plugin here: http://reboltutorial.com/plugins/logo-badge/ 我在这里有一个Activex插件: http : //reboltutorial.com/plugins/logo-badge/

I tried by adapting the script http://forums.devarticles.com/javascript-development-22/detecting-activex-objects-installed-in-ie-11041.html to 我尝试通过将脚本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>

but it doesn't work. 但这不起作用。

How to detect for any activex ? 如何检测任何activex?

First of all, use a proper method for testing 首先,使用正确的方法进行测试

// 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';
}

Then your code would look like 然后你的代码看起来像

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

Note that its the window we check, not the document. 请注意,它是我们检查的窗口 ,而不是文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM