JavaScript ActiveX对象
我有一个关于 javascript 中的 ActiveXObject 的问题。我在 Mozila FireFox 6.0.2 中尝试过这段代码
var AXobj = new ActiveXObject("WScript.Shell");
AXobj.SendKeys(key);
,但错误控制台显示 ActiveXObject 未定义。之后,我尝试了这个:
var AXobj = new DOMParser("WScript.Shell");
AXobj.SendKeys(key);
但是,错误控制台显示:
错误:未捕获的异常:[异常...“安全错误”代码:“1000”nsresult:“0x805303e8(NS_ERROR_DOM_SECURITY_ERR)”位置:“file:///C:/Documents%20and%20Settings/Guest/Desktop /stuff/html/GML%20to%20JS.html 行:335"]
顺便说一句,我不想仅将 ActiveXObject 用于 SendKeys。我需要它来做更多的事情(比如写入文件......)并且,我使用 FireFox 而不是 IE 的原因是 FireFox 支持 HTML5。
I have a queastion about ActiveXObject in javascript. I have tryed this code in Mozila FireFox 6.0.2
var AXobj = new ActiveXObject("WScript.Shell");
AXobj.SendKeys(key);
But the error console says that ActiveXObject is undefined. After that, I have tryed this:
var AXobj = new DOMParser("WScript.Shell");
AXobj.SendKeys(key);
But then, the error console says:
Error: uncaught exception: [Exception... "Security error" code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)" location: "file:///C:/Documents%20and%20Settings/Guest/Desktop/stuff/html/GML%20to%20JS.html Line: 335"]
By the way, i don't want to use ActiveXObject only for SendKeys. I need it for more stuff (like writing in file... ) AND, the reason i use FireFox instead of IE is that FireFox supports HTML5.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ActiveX 是一项仅由 Microsoft 支持的专有技术...
它只能在 IE 中运行(谢天谢地)。
它还存在一些严重的安全问题,这是其他浏览器提供商从未采用它的一个重要原因。
ActiveX is a proprietary technology only supported by Microsoft...
It will only work in IE (thank goodness).
It also has some serious security concerns which is a big reason it was never adopted by other browser providers.
为此,您可以检查它是否是 IE,否则执行此操作
这样做。
喜欢:
只是一个建议。
For this you can check if it is IE then do this otherwise
do that.
Like:
just a suggestion.