Domanda

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/

È stato utile?

Soluzione

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));
}

Altri suggerimenti

Try test.charAt(i) in place of char[i]

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top