Hi T.J., I finally got around trying your recommendation and it worked flawlessly. Thanks a ton.
-- Kash On Jun 13, 3:32 am, "T.J. Crowder" <[email protected]> wrote: > Hi, > > String#escapeHTML doesn't do anything with embedded newlines; it > "Converts HTML special characters to their entity equivalents." > Newlines aren't special HTML characters, they're just whitespace. > > You can easily do what you want with a String#replace[1]: > > after = before.replace(/\n/g, "<br/>"); > > Be sure you do the replace *after* you escape the HTML, otherwise > you'll end up with the <br/> displayed literally. So: > > after = before.escapeHTML().replace(/\n/g, "<br/>"); > > I don't think browsers ever put a \r before the \n in textareas, but I > couldn't swear to it, so if it were me I'd probably hedge my bets and > optionally include it: > > after = before.escapeHTML().replace(/\r?\n/g, "<br/>"); > > [1]https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global... > > HTH, > -- > T.J. Crowder > tj / crowder software / com > Independent Software Engineer, consulting services available > > On Jun 12, 8:36 pm, Kash <[email protected]> wrote: > > > Hey Guys, > > > I am using the escapeHTML() string function in the following manner. > > > $('divElement').update( stringInput.escapeHTML() ); > > > Now my stringInput is something like "This is a test\nThis should be a > > new line!!!" > > > The \n does not show up as a new line on my HTML page. Was hoping > > someone could guide me what a work around could be so that a new line > > shows up on my HTML page. I did try putting <br/> instead of > > \n. But it just shows up as something weird on the HTML page. Please > > help. > > > P.s: I would still like to keep using escapeHTML, so a solution which > > doesn't involve removing escapeHTML from the code would help... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---
