/ Published in: JavaScript
This will need to be either embeded or included and you can then just use this as such
myNewString = myStringVariable.nl2br();
myNewString = myStringVariable.nl2br();
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function nl2br(){ var text = escape(this); var re_nlchar = null; 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 ; } text = (re_nlchar != null) ? unescape(text.replace(re_nlchar,'<br />')) : unescape(text); return text } String.prototype.nl2br = nl2br;