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 to the CF scene
    Join Date
    Mar 2012
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    inserting special symbols

    Hey. Yes, I'm just starting at the beginning and what I'm trying to understand today is adding special characters such as line break, quotes, etc. into Javascript. I'm missing something, however. Can someone please assist?

    What I'm trying to do is add a line break without having it show /n on the screen.

    My Code:

    <html>
    <head>
    <title>Exercise 6-20</title>
    </head>

    <body><pre>
    ********* *** * *\n
    * * * * *** * *\n
    * * * * ***** * *\n
    * * * * * * *\n
    * * * * * * *\n
    * * * * * * *\n
    * * * * * * *\n
    * * * * * * *\n
    * * * * * * *\n
    * * * * * * *\n
    * * * * * * *\n
    ********* *** * * *\n

    </pre>
    </body>

    </html>

    Thank you,
    H

  • #2
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    just remove the \n and use the keyboard's Enter key to create the line break.
    Code:
        <body>
            <pre>
    ********* *** * *
    * * * * *** * *
    * * * * ***** * *
    * * * * * * *
    * * * * * * *
    * * * * * * *
    * * * * * * *
    * * * * * * *
    * * * * * * *
    * * * * * * *
    * * * * * * *
    ********* *** * * *
            </pre>
        </body>
    works in IE9

    Haven't tested other browsers

  • #3
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    K. It works in Firefox also.

    So... if that's the case, why use /n ? What's that for?

  • #4
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    The <pre> element maintains line breaks and spaces in its content.

    You can use \n to insert line breaks in dynamically created strings that are not contained in a <pre> for example.

  • Users who have thanked webdev1958 for this post:

    hmcka (03-08-2012)


  •  

    Posting Permissions

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