...

View Full Version : inserting special symbols



hmcka
03-08-2012, 03:20 AM
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

webdev1958
03-08-2012, 03:25 AM
just remove the \n and use the keyboard's Enter key to create the line break.


<body>
<pre>
********* *** * *
* * * * *** * *
* * * * ***** * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
********* *** * * *
</pre>
</body>works in IE9

Haven't tested other browsers

hmcka
03-08-2012, 03:47 AM
K. It works in Firefox also.

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

webdev1958
03-08-2012, 03:56 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum