I am passing data from a textarea to a div with javascript. The problem is the div is ignoring line breaks.

document.getElementById('layer1').innerHTML =  document.getElementById('reply').value.replace("\n", "<br /><br />");

e.g... i entered this in the textarea

test1


test5


test6


the result was in the div

test1

test5 test6


the div is completely ignoring the line breaks. any idea why?

line breaks.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta name="generator" content=
    "HTML Tidy for Windows (vers 25 March 2009), see www.w3.org">
    <title></title>
  </head>
  <body>
	<textarea onclick="tfr()" id='ta'></textarea>
	<div id='dv'></div>

	<script type="text/javascript">
		function tfr() {
		    document.getElementById('dv').innerHTML = document.getElementById('ta').value.replace(/\n/g, "<br /><br />")
		}
	</script>
  </body>
</html>

i tried that code and it doesn't work. it still appears as

test1

test5 test6


rather than

test1


test5


test6

Tested here in Chrome, Firefox, Safari(pc), Opera, and IE8.

They all give the correct result.

Did you by any chance omit the /g flag?
If not, please post your code.