JavaScript ActiveXObject

淺唱寂寞╮ 提交于 2019-12-25 02:18:34

问题


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.


回答1:


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.




回答2:


For this you can check if it is IE then do this otherwise do that.

Like:

Function exampleFunction()
{
if ($.browser.msie) { /* IE */
                //Your code

            else {
                //Your code
            }
}

just a suggestion.



来源:https://stackoverflow.com/questions/7421231/javascript-activexobject

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