I have microsoft edge version 40, it is really old but I can't update my Edge without updating my W10 OS, and thats like 4 gigs or something and I don't have the SSD space to spare. Plus there are reports this is happening on the newer versions too.
Anyway here is the following code that causes the error:
varvalue = varvalue.replace("'", '');
varvalue = varvalue.replace('"', '');
And when I'm on edge I get this error in the console works in all other browsers including IE:
Unhandled promise rejection TypeError: Object doesn't support property or method 'replace'
When I comment out the code causing the error, it goes away and everything is fine, so I KNOW that it is these lines causing the issue. Only for Microsoft Edge though.
Basically I'm checking if varvalue contains either an apostrophe or double apostrophe (which it usually will for whatever reason) then it needs to be stripped out of the string, so I'm just looking for any of those in the string and removing them.
It appears that Edge does not think varvalue is a string, but rather an object.
This is probably caused by the method in which it receives the data, and not these replace functions.
Related
I've recently updated from an older 1.x version of jQuery to the latest 2.2.1 and mostly it seems to be running just fine. Unfortunately I'm constantly receiving 2 error messages in raygun which I don't know how to handle:
The first one is Cannot find function createHTMLDocument in object and only happens in Firefox 24.0 under Win 7 (according to raygun).
The second one states Cannot convert a Symbol value to a string and only happens in Firefox 38.0 in the OS reported as Linux Core.
Both errors don't provide any stack trace (at function () line null, column null (null:null)) and I can't reproduce neither one myself using the same FF & OS version using browserstack.
I'm not quite sure if those errors where already happening earlier in the older jQuery version since I was loading this version from a different CDN which didn't provide any useful errors from within jQuery at raygun at all due to same origin stuff.
One more thing: If it turns out, that those errors actually happen in some legacy browsers which just report an incorrect version 24 & 38, I'd also be happy to know, how to detect those browsers early so that I can show them an appropriate message before the errors occur.
I'd really appreciate any help/input on how to tackle this issue since I'm a little clueless by now.
Thanks
I'm developing a page with the following libraries;
jQuery (1.7.2) (older version because of a dependency issue, but have tried up to 1.9.1, doesn't fix issue).
Backbone (1.1.0)
lodash (2.4.1)
modernizr (2.7.1)
gsap (1.17.0)
The page use canvas and gsap for animation. Everything works great in IE11, Chrome, Safari, Firefox, and IE8 (animations disabled for IE8), but IE9 and 10 just throw this error in the console over and
unable to get property 'replace' of undefined or null reference
The line referenced is in jquery.js, line 622, which is the return statement in this code:
// Convert dashed to camelCase; used by the css and data modules
// Microsoft forgot to hump their vendor prefix (#9572)
camelCase: function( string ) {
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
},
I can't figure out how to determine what part of MY code caused this jQuery code to fire, so I'm unsure as to what may be the issue on my end.
Does anyone know a fix for this? Or alternatively, how I can view what part of my code caused this jquery code to fire (using IE dev tools)?
Turns out the issue wasn't something inherently wrong with IE, but rather I was trying to access an object which didn't entirely exist yet. The other browsers this was not an issue (perhaps their JS engines were just fast enough for it to be a non-issue), but I've now added checks to ensure all the relevant content has loaded before executing the problematic function and the issue seems to be gone. Thanks for the help, all.
What kind of tool are you using for debugging? I have a solution for you for Chrome debug console
1. First go Find the jquery script file in the console, right click and select "Blackbox script" it is going to be ignored while debugging, only your files are going to be considered
2. Activate break on errors and a breakpoint is going to be triggered on the line of code where the exception is occurring
Check JavaScript: Is there a way to get Chrome to break on all errors?
and https://developer.chrome.com/devtools/docs/blackboxing
Maybe I'm wrong here but is it possible that IE8-9 "string" is a reserved word? Maybe not. But the only time .replace would show that message is if you were not feeding it a string.
camelCase: function( string ) {
if(!string){
console.log("string is falsy", string);
return string;
}
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
},
TypeError: Unable to get value of the property 'childNodes': object is null or undefinedundefined
After making a long list of modifications to my application in order to support IE8, including:
running all of the views in their compiled form through W3C validator, setting up xdomain.js proxy to support CORS API calls, making some general restructures, etc.
I was very disappointed to find out that IE8 still throws this weird error at me, while IE9 works perfectly fine.
Making changes to the Angular-seo package to prevent it from running when the client is an IE browser.
Any ideas on what can it be?.
Make sure that all your tags are closed properly. I just spent hours trying to figure out what the problem was, until I noticed this in my code:
<span>some text<span>
I finally realized I didn't close the <span> tag properly. After that everything just worked.
Without the code you are running it is a bit difficult. However there is a command to use for debugging. First you need to identify which variable might not contain an object [i.e.
"object is null or undefined"].
For example, parent, then you can use
//next look to see if parent is something
if('undefined'==(typeof parent)) alert("variable empty:parent");
Once you find something that is empty that you are expecting to be an object then you can go trace back from there. Also use a browser debugged tool, to identify the line number of the error.
Often if using the child nodes, you may not have the right level or you need to access as an array i.e. you need something like.
parent.childNodes[0].childNodes[0].value
In IE you are also dealing with unsupported functions. So getElementById will work but some other similar ones do not. Again typeof can be useful.
//next ensure function supported
if( 'undefined'==(typeof document.getElementsByClassName) ){
alert("Not Supported"); // notice ^ no () required here
//...add code to handle differently when not supported
}
This may reveal if you can use a function
IE8 is so old and non-standards compliant it doesn't support childNodes[]. http://quirksmode.org/dom/core/#t70
I have a web app with a JavaScript file using code like the following:
var foo = {a:'b',c:'d',e:'f',};
On my computer, IE9 (9.0.8112.16421) works correctly; the JavaScript is parsed and executed as on Chrome/FF/Safari. Another user claims to have the same version of IE, yet gets this error in the Developer Tools Console:
SCRIPT1028: Expected identifier, string or number
blob.js?modified=1304026278, line 524 character 136
Column 136 is the trailing comma/closing brace for the object literal.
I've 'fixed' the code so the user should have no more problems, but I'm wondering:
What could make the same version of IE on two different computers treat the JavaScript differently?
One of the reasons may be that user has pressed the "Compatibility View" button. The trailing comma causes syntax error in IE7 document mode.
Its most likely due to a browser setting suppressing the error on your browser.
I don't know if this is a know problem in IE8, but I can't really find any info on it.
// The regex can vary but has to have a non-matching group defined:
var re = /^(\s)?[\d]+$/i;
// We call it with a string...
re.exec("2");
// We call it with a number...
re.exec(2);
Firefox and Chrome (can't try it in Opera right now) have no problem with either calls. But on IE8 the second call fails with an "Object does not support that property or method".
Is this a known bug or something?
I saw the same issues in an Ext JS 4 application. Lots of things were failing as Ext JS appears to pass numbers in the exec() method at times. The issue turned out to be a third party library SyntaxHighlighter. Removing this reverted the default IE8 behavior and re.exec(2); worked.
I'd suggest cutting down the external JS that you include in your app until you find the culprit.
Since exec takes a string I would make sure you are passing a string. By passing a number in I would say you are trying to count on grey areas of the way browsers implement javascript.