...

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



KrazyKid
01-30-2003, 01:00 PM
Hello,

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!

whammy
01-31-2003, 12: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")

;)

KrazyKid
01-31-2003, 06: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.

Thanks!

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum