Originally Posted by Old Pedant
I think Felgall missed the end of his answer.
I was concentrating on supplying an exact equivalent to the piece of code posted (and even then missed the i++ between the two calls). Of course a loop would take care of the entire code properly rather than just repeating the calls many times.
The MSIE solution is probably a good choice in this situation. The file:// references may not work properly in all other browsers so a full cross browser solution doesn't exist.