0

I'm having a weird behavior with IE:

After some modifications on a Javascript enabled web page of mine, IE9 is not testing a string value correctly. I tried the same page on Safari and Firefox and it works (Who said no surprise?)...

Besides, when running locally with the Visual Studio integrated localHost engine, the modified page runs fine! Once the page is uploaded and run from the host website (ASP.NET 4.0) It doesn't "work" properly...

Now I tried on another PC with IE8 and... it works fine!

I suspect I have to reinstall IE9 on my PC?

Q1 - What do you web Gurus say? Q2 - How to reinstall IE on Windows Vista?

Update: the bad behavior happened after I added a string variable of 4 chars length and testing like this:

var a = "abcd"; // Actually a value taken from a hidden field

if (a[2] == somevalue) { Do this } else { Do that }

There is NO SCRIPT ERROR, but the result of the branching is wrong!

Didier Levy
  • 3,393
  • 9
  • 35
  • 57
  • How about some code or testing on another computer with IE9 to be sure it's not an IE9 bug? :) – Joachim Isaksson Jan 20 '12 at 17:04
  • No need to reinstall IE9 if its a script error. Click F12 key while in IE9 and then click Script from the debugging tool and then Start Debugging to find the javascript error and fix that. Then you should be good to go. – Rob Jan 20 '12 at 17:05
  • @ Rob: It is NOT a script error and IE is not complaining about any error: it is a branching error! – Didier Levy Jan 20 '12 at 17:40
  • Test on another IE9 and if it always gives incorrect results, send a link to live demo that reproduces the problem. – duri Jan 20 '12 at 18:00
  • @ Rob: Thanks for the F12 hint: until now I was only using inside Visual Studio JScript debugger (together with localhost). Now I'm able to find out and fix the issue! – Didier Levy Jan 20 '12 at 21:34

1 Answers1

0

There is a bizarre misbehavior with IE9:

var a = "abcd"; // Actually a value taken from a hidden field

if (a[2] == somevalue) { Do this } else { Do that }

a[2] stays "undefined"! If you want it to work you must use the javascript substring function instead.

With Firefiox and Safari, a[2] is perfectly defined. And with the Localhost provided by Visual Studio it works fine as well!!! :-((

Didier Levy
  • 3,393
  • 9
  • 35
  • 57