سؤال

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/

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top