At that time, I found a lighter solution similar to a cross browser:
innerHTML with a rough overlay <pre>
<div id="bar"></div> <script> var string = "Preformatted \n" + "string \r" + "with \r\n" + "assorted \n\r" + "line breaks"; document.getElementById('bar').innerHTML = "<pre>"+string+"</pre>"; </script>
\r\n becomes the only return
\n\r double return
Imperfection: IE 10 7 compatibility mode add a space at the end of the last line.
Salvador
source share