2010-05-26 37 views
0

我有一個ActiveX插件在這裏: http://reboltutorial.com/plugins/logo-badge/如何檢測Javascript中的一些ActiveX?

我試圖通過修改腳本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?

+0

你的代碼中有一些語法錯誤,比如'document.loction.href' – 2010-05-26 05:42:14

+0

謝謝它是從其他站點複製並粘貼的。我糾正了。 – 2010-05-26 18:53:30

回答

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"; 
} 

注意其窗口我們檢查,而不是文件。

+0

真的很棒的文章,我在搜索谷歌時找不到它,謝謝。 – 2010-05-26 18:55:17

相關問題