Ken Ward's JavaScript Tutorial 2

Ken Ward's New Java Script Tutorial

New lines in JavaScript


Ken Ward's JavaScript Tutorial 1 In our previous alert, all the text was on one line. Sometimes we want to put the text in two or more lines. You can see text in two or more lines in the following alert:

We achieve this by using the following code:

<script type="text/javascript">
<!--//
function alert2()
{
alert ("Don't forget the curly
"+
"
brackets - \nThey are essential!");

}
//-->
<
/script>

I don't suppose I have to tell you how we made a new line? That funny \n thing gave the game away! You couldn't miss it. (I bet I could if I were learning JavaScript, though!)


exclam.gif (180 bytes)If we break a line of text, that is, begin on one line and end on another, then we must end one part with a quotation mark and a plus sign ("+) and begin the new line with a quotation mark (").


Let's put some data into the program next!

Next:


Contents

[If you need to learn more about HTML visit the HTML Tutorial]

I am always pleased to hear from you.
Send your comments to