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
Related
I am working on a web site using angularJS. The project is made on Visual Studio so the server is IIS.
When using Chrome, everything is working fine. But my boss wants also this site to work fine with Internet Explorer 11, in case of some clients are only using this browser.
The problem is that i have an error at an unexpected place when is use IE, for example :
Syntax Error : Caractère Incorrect ( that's french, it means Invalid character )
at getConnectedUser (http://localhost:54579/mypath/myfile.js:121:13)*
And if i open this file at line 121
vm.connectedUser = JSON.parse($cookies.get("userLogged"))
and the 13th character is the v from vm ( since i have some tabs )
the wole function is :
function getConnectedUser() {
vm.connectedUser = JSON.parse($cookies.get("userLogged"))
}
Which is quite normal according to me...
I don't know how to solve this, since the error does not seem to come from the code but from the interpretation of my browser.
I have read that some keywords were not supported to declare variables, like const. I use "let" to declare my variables and it is supported by IE 11 according to this site
EDIT : i also use "var" ( for example : var vm = this )
It would be very helpful if you have some ideas to find a solution.
Thanks for reading,
Sonny
So
I tried to apply what you guys asked, here is what i've got :
The problem actually comes from my cookies, IE can't read it correctly, I get undefined when trying to log my cookie's type, instead of getting "string".
So i went to a different part of the projet, where this cookie is created.
I try to log the cookie just after it is created so it can't be alterated:
var myObject = { "value" : "sonny" }
var stringified = JSON.stringify(myObject) // myObject is validated by jsonlint.com
try {
$cookies.put("userLogged", stringified, {})
console.log("ok")
}
catch (error) {
console.log(error)
}
// i got "ok" in logs , the try part is successful
console.log("fresh cookie : ")
console.log(typeof $cookies.get("userLogged"))
// On Chrome Console : string
// On Ie Console : undefined
console.log(typeof JSON.parse($cookies.get("userLogged")))
// On Chrome Console : object
// On Ie Console: Not logged , i have the Syntax Error Message
So the problem seems to be that IE can't read the cookie i just set before.
Using IE developers tools , i can see the cookie line :
Value : %7B%22value%22%3A%22sonny%22%7D
each special character ( '{', '"' and '}' ) is replaced by "%7B" , "%22" and "%7D"... It is exactly the same with chrome developers tools so i don't think it should be a problem.
Can IE actually read cookies using angular and ngCookies ?
As everyone mentioned in comments.
It is difficult to solve the issue with information provided.
So the best option could be using IE developer tools and debug your application.
Here is how I can troubleshoot the issue.
function getConnectedUser() {
// forces browser to stop at below line
debugger;
var loginInfo = $cookies.get("userLogged"); //put a debug point
// check for loginInfo existence and typeof loginInfo should be string
if (loginInfo && typeof loginInfo === 'string'){
vm.connectedUser = JSON.parse(loginInfo);
}
}
Put a break point in the getConnectedUser function
Check the value of $cookies.get("userLogged"), whether it is returning data or not
yes => check the type of data. It must be a valid JSON string format.
No => do the corresponding actions
I found this code;
navigator.appVersion.match(/MSIE ([\d.]+)/)[1];
For detecting browser version. This code works in IE 8 below but not on google chrome. The error in google chrome says;
Uncaught TypeError: Cannot read property '1' of null
and it points to the line where this code belongs;
navigator.appVersion.match(/MSIE ([\d.]+)/)[1];
Any idea how to fix this issue?
just to make things clear what i'm trying to accomplish here is to detect the browser version:
var version = navigator.appVersion.match(/MSIE ([\d.]+)/)[1];
if(version <= 8.0)
{
execute code;
}
Everything works fine in IE but I got an error in google chrome which is:
Uncaught TypeError: Cannot read property '1' of null
and it points to the line where this code belongs;
navigator.appVersion.match(/MSIE ([\d.]+)/)[1];
match can return null if regexp don't find anything. So you must first get matches and check have you any match or not. Try this:
var ieMatches = navigator.appVersion.match(/MSIE ([\d.]+)/);
var isIE = !!ieMatches[1];
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.
I am doing a very simple:
console.log("Testing");
along with :
alert("testing");
The Alert works (so I know the javascript is working) but I'm unable to see the log. When I use Firefox I get the following error:
The Web Console logging API (console.log, console.info,
console.warn, console.error) has been disabled by a script on this
page.
What is going on? I have looked at the following topics, but none have helped:
Chrome: console.log, console.debug are not working
console.log quit working in Chrome
Console.log not working in Chrome [closed]
why does console.log not output in chrome?
Console.log not working at all
I have also made sure that the funnel is working and that logging is turned on.
What else could the problem be?
I just came across this problem after a Firefox update and managed to fix it. Here's the code that caused the problem:
/* IE fix that allows me to still log elsewhere */
if (typeof(console)=="undefined") {
var console = {
output: null,
log: function (str) {
// we can't emulate the console in IE, but we can cache what's output
// so that IE users can get it via console.output
if (!this.output) this.output = new Array();
this.output.push(new String(str));
}
};
window.console = console;
}
In the previous version of FireFox, "var console;" wouldn't get executed. Now it seems to have added some sort of branching/prediction mechanism. Seeing that I may define a variable called console with global scope, it disables window.console.
I fixed this issue by renaming var console; to var cons;
/* IE fix that allows me to still log elsewhere */
if (typeof(console)=="undefined") {
var cons = {
output: null,
log: function (str) {
// we can't emulate the console in IE, but we can cache what's output
// so that IE users can get it via console.output
if (!this.output) this.output = new Array();
this.output.push(new String(str));
}
};
window.console = cons;
}
I still need to test this to make sure it does what I expect in IE, though. I just need to find a copy of IE without a console (I think 9 or below).
I just wish that Firefox would tell you what line of what script disabled the console - that would be nice.
I had the same issue with a Magento e-commerce site (version 1.6.2.0).
I fixed it commenting the following lines in /js/varien/js.js:637
if (!("console" in window) || !("firebug" in console))
{
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
window.console = {};
for (var i = 0; i < names.length; ++i)
window.console[names[i]] = function() {}
}
This fix is only (obviously) for Magento sites.
Turns out the theme developer had added firebug lite to the theme without me knowing. Turning it off fixed the problem.
I think the page you are viewing when trying to log via console.log() has a script in it which overwrites the property window.console.log. Usually this property is preset with a function by the browser but you a script may override it.
First suggestion: Do you use any other dev tools that use console? On Firefox I had the same problem with Firebug running on background without me noticing it, after closing firebug the error went away. Here's a possiple duplicate thread: Firefox Web Console Disabled?
Second, if it is overridden by some script, then one by one disable scripts and see which draws the error.
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.