3

I tried fixing my application to work on IE9 browser (with IE9 standards mode).

However I am getting some undefined javascript errors..

I have the following piece of code in a js file.

1.

if(escape(String.fromCharCode(111)).toLowerCase() != "abc")

{

    //code

}

I get error 'escape' is undefined.

2. In some js files, I get errors "Array is undefined" for such piece of code

//1
function abc(){

this.abc = new Array();

}


//2

var cde = new Array
(

  "aaa","bb","cc",

  "dd","eee","ff",  

);

However these errors do not occur for IE8 standards mode and other modes.

Please let me know why these errors are coming and how to fix such errors.

3 Answers 3

2

While Ryan's answer fixes the issue, the problem here is the trailing comma;

"dd","eee","ff",

Sign up to request clarification or add additional context in comments.

Comments

0

Instead of using new Array(...), can you simply say...

this.abc = [];

and...

var cde = ['aaa','bb','cc','dd','eee','ff'];

...?

2 Comments

The can be many entries in cde (around 240) . What is IE9 expecting ? How to handle undefined for escape
Regarding the escape() issue, I haven't encountered any undefined errors in trying to do what you illustrated. Maybe if you show the whole code snippet, things will become clearer.
0

Your abc function turns itself into an array object; this is window. Maybe the context of this has changed or was misunderstood somewhere, and the code is inadvertently redefining window or its properties. That could explain why globals like Array and escape are undefined. (Not sure why it would only affect IE9 standards mode, though.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.