However, I recently needed to get a part of a string using these arguments, parseInt it, and add one to it. The code I came up with worked fine in NS, but ended up checking the wrong part of the string in IE, causing it to return NaN and place it in the wrong spot.
The string was a TD's innerHTML, which was something like
<b>#</b> guests, <b>#</b> members, ....
All the #'s are actual numbers, but they vary from time to time, so they can be 1, 2, 3, or even 4-digit numbers, which is why I'm using a more complicated code than if it were always a fixed number of digits.
Now, here's the code I used:
Code: Select all
temp=tds[p].innerHTML;
temp1=temp.substring(0,temp.indexOf("guests, <b>")+11);
temp=temp.substring(temp.indexOf("guests, <b>")+11,temp.length);
temp2=temp.substring(temp.indexOf("</b>"),temp.length);
temp=temp.substring(0,temp.indexOf("</b>"));
temp=(parseInt(temp)+1).toString();
tds[p].innerHTML=temp1+temp+temp2;Now, this works fine in NS, and after rewriting the TD's innerHTML with the new string, it is EXACTLY the same except the number of members is one greater.
However, in IE, the code gets for temp1 <b>#</b> guests,
and all the other substrings() I use return something different than in NS, and end up checking the u in "guests" for the number, of course then returning NaN, so that the end result written to the TD is:
<b>#</b> gNaNuests, ...
The part in BLUE is the part that shouldn't be there, as well as the number of members does not change.
Since the code works in NS, something must be right. But then why does it get the wrong result in IE?
Is there a difference in one of these two functions from NS to IE? If so, can someone pleae tell me what it is so I can fix the code to work cross-browser?
Thanks in advance to anyone who can help (and to those who can't help, but they try anyway).
-IMP