Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Passing '\n' to JavaScript through ASP

    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!

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    First of all, it's \n - not /n.

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

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

    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Thanks..

    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!

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yeah, that kind of thing really depends on the situation...
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •