View Full Version : Passing '\n' to JavaScript through ASP

01-30-2003, 02:00 PM

I want to be able to send a string to JavaScript through an ASP tag such as

alert('Hello \n World');

But the HTML source code output from the asp Response.Write is syntacticly what I want, alert('Hello \n World') the javascript will output the alert as:

Hello /n World

What is the escape sequence code that I need for a JavaScript "/n" new line to be parsed correctly by both engines?

Make sense?

Thanks in advance!

01-31-2003, 01:10 AM
First of all, it's \n - not /n.

And this should replace CarriageReturns/LineFeeds with the \n character:

mystring = Replace(mystring,vbCrLf,"\n")


01-31-2003, 07:11 PM
Thanks for pointing out my error ...whoops, well you got the point anyways..

I will try the replace method next time, what my real problem was really I had to use the & "quot;" instead of double quotes in my string to be passed to the JavaScript from the ASP.


02-01-2003, 02:48 AM
yeah, that kind of thing really depends on the situation...