简体   繁体   中英

Javascript error (SCRIPT5022) in IE10

I wrote this code:

AjxException.reportScriptError =
 function(ex) {
if (AjxException.reportScriptErrors && AjxException.scriptErrorHandler && !(ex    
       instanceof AjxException)) {
    AjxException.scriptErrorHandler(ex);
}
throw ex;
};

it's fine in all browsers including IE9,8 but I got this error in IE10:

 SCRIPT5022: InvalidCharacterError 

mentioned throw ex; Why this happens in IE10 and how could I solve this?

eventually, I figured out what was wrong with the codes: the javascript code was written for old versions of IE: IE7, IE8, IE9 and used this line:

var ninput = document.createElement(AjxEnv.isIE ? ["<INPUT type='",type,"'>"].join("") :  
"INPUT"); 

in order to create INPUT element. it works fine in older versions of IE but not in IE10 . So, I had to use this one instead:

var ninput = document.createElement((AjxEnv.isIE && !AjxEnv.isIE10up)? ["<INPUT 
type='",type,"'>"].join("") : "INPUT");

now, it's working.

Are your files saved without a BOM (Byte Order Mark)? Those can often throw off parsers and wreak havoc.

I'd also recommend chopping up your code in to as many lines as possible to determine which line has the issue and then remove it for testing purposes and that way you'll be able to quickly determine what the issue is.

For example you may be referring to an object of the wrong type (working with an array and the object happens to be a string for example) so if you remove an object and it works (or works slightly better) try alert('typeof myObject = '+typeof myObject); to give you some further insight.

Also it looks like you have multiple instances of ex , make sure you aren't using a string and a function both named ex .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM