/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function nl2br(text){ text = escape(text); if(text.indexOf('%0D%0A') > -1){ re_nlchar = /%0D%0A/g ; }else if(text.indexOf('%0A') > -1){ re_nlchar = /%0A/g ; }else if(text.indexOf('%0D') > -1){ re_nlchar = /%0D/g ; } return unescape( text.replace(re_nlchar,'<br />') ); }