最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - JavaScript ActiveXObject - Stack Overflow

programmeradmin3浏览0评论

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.

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.

Share Improve this question edited Sep 14, 2011 at 18:43 gen_Eric 227k42 gold badges303 silver badges342 bronze badges asked Sep 14, 2011 at 18:33 SmRndGuySmRndGuy 1,8195 gold badges32 silver badges50 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 15

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.

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.

发布评论

评论列表(0)

  1. 暂无评论