JavaScript ActiveXObject - javascript

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.

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.

Related

How do I determine what exception was thrown?

I work on a script that is added to hundreds of different websites in ways that I can't always predict, particularly when code is loaded in an iframe. In my code I've got a try/catch block setup to handle the exceptions. It's something like this:
var vals = {};
try {
vals.hostname = window.top.location.hostname; // will throw DOMException if loaded in iframe
< more code which might throw other exceptions >
} catch (e) {
if (e instanceof DOMException) {
vals.hostname = window.location.hostname;
} else {
<do something different>
}
}
e instanceof DOMException works awesome on Chrome, but it turns out that on Firefox and Safari, e instanceof DOMException is false on those browsers. I've done a lot of searching and for some reason can't seem to find anybody who explains how to check the exception type in a browser agnostic way.
Edit: Okay, Chrome is throwing a DOMException, but Firefox (and presumably Safari) are just throwing a generic "Error":
Error: Permission denied to access property "hostname"
I think that means I can't do anything with the specific error on other browsers.

error from IE9 while creating UserManager in oidc-client.js

I have the following lines in my app.js file:
var settings = {
...
...
};
alert('1);
var mgr = new Oidc.UserManager(settings);
alert('2');
...
Everything works great in every browser except IE9 (and below).
In IE9 '1' comes up and then I get javascript error:
SCRIPT438: Object doesn't support property or method 'apply'
Is it something I am doing wrong or for it to work it must be IE version > 9?
Thank you
Mark

IE ERROR 'object doesn't support this property or method when is use window.dialogargument()

I am getting error like "Object doesn't support this property or method" in IE only, when I use window.dialogArguments method. It's working fine in the remaining browsers (Mozilla, Chrome).
Sample code:
if(window.navigator.appName=="Microsoft Internet Explorer"){
window.dialogArguments.setCopyFromValues(segmentCode,segmentName,status);
window.close();
}
I am getting error window.dialogArgument place.

Parallel.js have problems with Blob in IE

I need to execute functions in "parallel" and I use parallel.js:
var p = new Parallel(items);
var fn1 = function (item) {
doSomething(item);
};
p.map(fn1).then(function () {
otherFunction();
});
But IE shows the following error:
[Q] Unhandled rejection reasons (should be empty): (no stack) SecurityError
HTML7007: One or more blob URLs were revoked by closing the blob
for which they were created. These URLs will no longer resolve as
the data backing the URL has been freed.
How to fix this error?
I had review parallel.js page in IE and all examples work fine.
I use Durandal, Breeze and Knockout.
In Firefox shows the following error:
[Q] Unhandled rejection reasons (should be empty):
["(no stack) [Exception..... location: "<unknown>"]"]
and in Google Chrome no shows error, but parallel.js no work.
In case you're still having trouble with this, to make Parallel.js work in Internet Explorer you have to include the evalPath option, as mentioned on the website:
evalPath (optional): This is the path to the file eval.js. This is
required when running in node, and required when requiring files in
browser environments (to work around cross-domain restrictions for web
workers in IE 10).
This also applies to IE 11.
So your code will become:
var p = new Parallel(items, {evalPath: [PATH_TO_EVAL_JS]});
Where [PATH_TO_EVAL_JS] points to eval.js.

JQuery security error in Opera and Internet Explorer

I am developing an app for social network which works in IFrame. The app works just fine in Google Chrome and Microsoft Firefox browsers, but in Opera 12.15 JQuery library v1.10.1 fails to load with security error Unhandled error: Security error: attempted to read protected variable on line 1513.
The screenshot is here:
It looks like the same bug exists in Internet Explorer 10.
How to deal with it?
UPDATE:
I have made dirty hack by commenting the lines 1513-1517 in the code of jquery:
// Support: IE>8
// If iframe document is assigned to "document" variable and if iframe has been reloaded,
// IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
/*if ( parent && parent.frameElement ) {
parent.attachEvent( "onbeforeunload", function() {
setDocument();
});
}*/
The functionality of my app seems to work now, maybe it is necessary to create issue in JQuery repo...
Bug report was created - http://bugs.jquery.com/ticket/13980.
Bug is now fixed.
Add this before you include JQuery:
var isIE11 = !!(navigator.userAgent.match(/Trident/) && !navigator.userAgent.match(/MSIE/));
if (isIE11) {
if (typeof window.attachEvent == "undefined" || !window.attachEvent) {
window.attachEvent = window.addEventListener;
}
}
Hope it helps, It worked for me.

Categories

Resources