IE7 doesn't support indexing into strings with [i]
, you have to use charAt(i)
. E.g.:
var test = "hello";
for (var i = 0, len = test.length; i < len; i++) {
alert(test.charAt(i));
}
Pregunta
Anyone knows why this isnt working in IE7 and how I can make it work?
var test = "hello";
for (var i = 0, len = test.length; i < len; i++) {
alert(test[i]);
}
or see http://jsfiddle.net/75Cqt/
Solución
IE7 doesn't support indexing into strings with [i]
, you have to use charAt(i)
. E.g.:
var test = "hello";
for (var i = 0, len = test.length; i < len; i++) {
alert(test.charAt(i));
}
Otros consejos
Try test.charAt(i)
in place of char[i]