How do I detect if ActiveX is enabled in the browser of client?

穿精又带淫゛_ 提交于 2019-11-26 21:10:17

问题


How do I detect if ActiveX is enabled in the browser of client?

I tried following code, but it's not working in Firefox.

window.ActiveXObject not working in Firefox

any ideas?

check the example here: http://jsfiddle.net/qXSvQ/2/

I get false when I run this example.


回答1:


ActiveX objects do not exist in anything but Internet Explorer. If you're trying to use them for XMLHTTPRequests, use the XMLHTTPRequest() object instead, using feature detection.

if ("ActiveXObject" in window) { /* Do ActiveX Stuff */ }
else { /* ActiveX doesnt exist, use something else */ }



回答2:


What isn't working? Is that throwing an error in FF? How about

var hasAX = "ActiveXObject" in window;



回答3:


Below code should work, It is working on IE6 & FF 3.6.12 atleast.

if(typeof(window.ActiveXObject)=="undefined"){
    alert("ActiveX Object not supported");
}else {
    alert("ActiveX Object  supported");
}


来源:https://stackoverflow.com/questions/4313438/how-do-i-detect-if-activex-is-enabled-in-the-browser-of-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!