I'm trying to parse some text into a textarea control and at the same time replace all
with ordinary line break chars.
I have been able to do it in windows by replacing
with CR
(it didn't work with CRLF
strangely enough, it gave me linebreak + empty space) but I'm afraid that this code won't work in Unix/Mac because they use LF
for line break.
Is there any way to use the system default line break char in javascript? Something similar to Environment.NewLine in .Net
(I wasn't able to write backslash in this editor but I use \r
for CR
and \n
for LF
)
Edit: I should probably mention that everything works with FF, it's as always internet explorer (8) I'm having problems with.
Edit2:
I can reproduce my problem with this code. When I run it in IE8 I get "row1 row2" but when I run it in FF I get real line breaks:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<script type="text/javascript">
function fill() {
var text = "row1<br /><br />row2";
$('#fill_me').text(text.replace(/<br \/>/g, '\n'));
}
</script>
</head>
<body onload="fill()">
<textarea rows=10 cols=100 id="fill_me"></textarea>
</body>
</html>