HTML and CSS Reference
Figure 4.1 Using the alert() method with Firefox (left) and Internet Explorer (right).
var message1="Match your Quotes and ";
var message2="Beware of Little Bugs ";
alert(message1 + message2);
Two variables, message1 and message2 are assigned text strings.
The alert() method contains a string of text. Buried in the string is a backslash se-
Table 3.1 on page 54). The \n causes a line break between the two strings. The rea-
son for using the \n escape sequence is because HTML tags such as <br> are not
allowed in this dialog box. After the alert dialog box appears on the screen, the
program will stop until the user clicks the OK button.
The alert() method not only accepts literal strings of text, but also variables as ar-
guments. The + sign is used to concatenate the values of the two strings together
and create one string. That string will appear in the alert dialog box as shown in
the output in Figure 4.2.