如何检测客户端浏览器中是否启用了ActiveX?
问题描述:
如何检测客户端浏览器中是否启用了ActiveX?
How do I detect if ActiveX is enabled in the browser of client?
我尝试了以下代码,但它在Firefox中无效。
I tried following code, but it's not working in Firefox.
window.ActiveXObject not working in Firefox
任何想法?
查看此处的示例: http:// jsfiddle.net/qXSvQ/2/
运行此示例时,我得到 false
。
I get false
when I run this example.
答
除了Internet Explorer之外,其他任何内容都不存在ActiveX对象。如果您尝试将它们用于XMLHTTPRequests,请使用XMLHTTPRequest()对象,使用特征检测。
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 */ }