mothra
05-17-2004, 05:07 PM
I'm finding that innerHTML is returning some 'extra' chars, probably a carriage return and or line feed on certain elements (such as <li>). IE and Mozilla handle this in different ways of course.
<li>Hello</li>
alert(thisLI.innerHTML + "FOO") ...In IE returns:
"Hello FOO"
alert(thisLI.innerHTML + "FOO") ...In MOZ returns:
"Hello
FOO"
It's funny though that in MOZ I can concat the above result with another string (such as "Hello FOOBAR") and it's like the line feed (or whatever) is not there. In IE it appears as a space in the concatenated string ("Hello FOO BAR")). So I have tried: thisLI.innerHTML.replace("\n","") and also "\r", "\n\r", "\r\n", etc... which have not worked.
I can use substring() to trim off the last char(s) but it's cludgy, trimming only 1 char makes it work in IE & MOZ but trimming more than 1 char causes mixed results. I know there are multiple chars on the end just not what they are and what the best way to get rid of them is. Can anyone suggest something?
Thank you.
<li>Hello</li>
alert(thisLI.innerHTML + "FOO") ...In IE returns:
"Hello FOO"
alert(thisLI.innerHTML + "FOO") ...In MOZ returns:
"Hello
FOO"
It's funny though that in MOZ I can concat the above result with another string (such as "Hello FOOBAR") and it's like the line feed (or whatever) is not there. In IE it appears as a space in the concatenated string ("Hello FOO BAR")). So I have tried: thisLI.innerHTML.replace("\n","") and also "\r", "\n\r", "\r\n", etc... which have not worked.
I can use substring() to trim off the last char(s) but it's cludgy, trimming only 1 char makes it work in IE & MOZ but trimming more than 1 char causes mixed results. I know there are multiple chars on the end just not what they are and what the best way to get rid of them is. Can anyone suggest something?
Thank you.