Closed GoogleCodeExporter closed 8 years ago
I "cleaned" the new code up some. First, inserting "\r\n" causes some lines to
be
indented by one space. Instead, insert only "\r". Below is the new updated
code. Note
that the insertAfter method is no longer needed.
//GDQV - Added the following method to make copy/paste work correctly.
// This "restores" the line breaks that IE stripped out when using
// .innerHTML property.
/** Replace <br>s with \r directly in DOM
*
* @param elem as DOM element with <br>s
*/
function replaceBrsWithCrLf(elem) {
var brs = elem.getElementsByTagName("br");
// Insert all the \r first. Work bottom to top, because I believe the
// collection is "live".
// Inserting \r\n causes a leading space to appear on some lines.
for (var i = brs.length; i-- > 0; ) {
var crlf = document.createTextNode("\r");
brs[i].parentNode.replaceChild(crlf, brs[i]);
}
}
Original comment by tbuch...@gmail.com
on 27 Sep 2007 at 3:26
I can repeat the bug. I'd rather not use \r for newlines since that's counter
to the
spec, and CR isn't used as eol in any OS except commodores and old versions of
MacOS.
Original comment by mikesamuel@gmail.com
on 23 Oct 2007 at 3:12
I played around a bit.
Thanks for suggesting the \r trick. I'm leery of how it'll affect other
browsers,
and this rewriting step isn't cheap so I'd rather not do it for all the
browsers that
don't have this problem.
I've managed to avoid browser detection thus-far, but I think using it here
yields
simpler code.
I fixed it by replacing <br> with \r\n but only on IE 6.
Original comment by mikesamuel@gmail.com
on 23 Oct 2007 at 4:49
I see you say you replaced <br> with \r\n. Notice my post on Sept 26, 2007;
using
\r\n causes some lines to be indented by a single space. I did not track down
the
reason/conditions for those lines, but changing to only \r fixed that problem.
Original comment by tbuch...@gmail.com
on 24 Oct 2007 at 4:42
@r62. use '\r' instead of '\r\n' on IE6 to separate lines.
Original comment by mikesamuel@gmail.com
on 14 Jan 2009 at 8:13
Original issue reported on code.google.com by
tbuch...@gmail.com
on 26 Sep 2007 at 3:58