Re: Problem with Javascript's String::split method in IE
Scott Sauyet <[email protected]>
| Newsgroups | gmane.comp.web.dom.wdf |
|---|---|
| Message-ID | <[email protected]> |
Gale, David wrote:
Thank you very much for your investigation.
> Well, I don't have a full answer for you, but some testing (replacing
> the linebreaks with :'s) reveals that IE's split function treats a
> sequence of tokens as one: splitting 'a:b' and 'a::::b' on ':' gives the
> same result. So, that explains why the second version gives 5 lines
> instead of 9.
I tried inserting something between consecutive linebreaks with a replace:
text = text.replace(/(\r\n|\r|\n)(\r\n|\r|\n)/g, "$1 $2");
And the results were even more bizzare. But perhaps there is some
variation of this that's workable.
> Also, I tried throwing a "alert(element.innerHTML)" in before the split,
> and played around with single-character lines a bit; it seems that IE
> will concatenate lines until it reaches at least 80 characters, and then
> it will start a new one, but only for the innerHTML of a code block.
> Really bizarrely, it doesn't even leave a space where the concatenation
> occurred, *if* the code block is inside a pre block. Removing the pre
> tag, everything becomes one line, but with spaces between each original
> line.
I hadn't seen that at all. This explains much of the problem, and makes
me thing that it's likely that my problem isn't easily solved. But
somehow IE is keeping the original format of the block, since the
display of the <pre><code> block *does* have the line breaks in the
right place. Hmmm.
> Ok, so I then went and swapped the order of the pre and code tags, so
> that the pre tag is inside the code tag. This actually turned out to
> give almost exactly what you'd wanted in the first place (each line is
> treated separately, though blank lines still fall prey to IE's odd split
> function--and the pre tags are, of course, present)...but only on IE.
> Firefox reports that innerHTML is "".
Strange, strange. So when's IE7 gonna replace IE6? Soon, please?! :-)
> Dunno if that helps at all; at this point, I'll be very interested if
> you find a solution. :-)
I'll keep working. Something must be able to help.
Thanks again,
-- Scott
Unsubscribe
[email protected]
List info
http://www.quirksmode.org/dom/list.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/wdf-dom/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/