Well, recently in a variety of direct code debugging, found that the problem may be a little more, let's write down, this essay may be updated from time to time, because I believe different browser differences between a lot.
Directly on the code
1 <HTML>2 <Head>3 </Head>4 5 <Body>6 <Script>7 varStr= "/part1/part2";8 var_list=Str.split (/[\\/]/);9 for(varI= 0; I<_list.length; I++)Ten { One varT= "_list[" +I+ "] : " + "\ '" +_list[i]+ "\ '"; A alert (t); - } - </Script> the </Body> - </HTML>
Open FF, Chrome, and IE8 separately to see the results, and find that the result is different
where FF and chrome results are the same
[0] = = "
[1] = ' part1 '
[2] = ' part2 '
And the IE8 is
[0] = ' part1 '
[1] = ' part2 '
So if you use _list by index, there will be different results between natural browsers.
For a different set of code, note that the var str = line of code differs
1 <HTML>2 <Head>3 </Head>4 5 <Body>6 <Script>7 varStr= "part1/part2/";8 var_list=Str.split (/[\\/]/);9 for(varI= 0; I<_list.length; I++)Ten { One varT= "_list[" +I+ "] : " + "\ '" +_list[i]+ "\ '"; A alert (t); - } - </Script> the </Body> - </HTML>
FF is still consistent with Chrome's performance,
[0] = ' part1 '
[1] = ' part2 '
[2] = = "
and IE8 is
[0] = ' part1 '
[1] = ' part2 '
The following example is no longer lifted, but one rule that can be found is that IE8 the empty string after the split is swallowed ... This is simply a no-no-words ...
However, when you do not use regular expressions, IE8 is not a problem, pay attention to var _list = Str.split ("/"); Instead of the regular var _list = Str.split (/[\\/]/);
<HTML> <Head> </Head> <Body> <Script> varStr= "part1//part2/"; var_list=Str.split ("/"); for(varI= 0; I<_list.length; I++) { varT= "_list[" +I+ "] : " + "\ '" +_list[i]+ "\ '"; Alert (t); } </Script> </Body></HTML>
Well, IE8 again full of blood ...