Java Reference
In-Depth Information
alert("First Script Block");
</script>
<p>Paragraph 2</p>
<script>
// script block 2
alert("Second Script Block");
</script>
<p>Paragraph 3</p>
</body>
</html>
Save the file to your hard drive as ch1 _ example2.html and then load it into your browser. When you
load the page, you should see the first paragraph, Paragraph 1 , followed by a message box displayed
by the first script block. The browser halts its parsing until you click the OK button. As you see in
Figure 1-2, the page background is white, as set in the <body> tag, and only the first paragraph is
displayed.
figure 1-2  
Click the OK button, and the parsing continues. The browser displays the second paragraph, and the
second script block is reached, which changes the background color to red. Another message box is
displayed by the second script block, as shown in Figure 1-3.
Click OK, and again the parsing continues, with the third paragraph, Paragraph 3 , being displayed.
The web page is complete, as shown in Figure 1-4.
The first part of the page is the same as in our earlier example. The background color for the page is set
to white in the definition of the <body> tag, and then a paragraph is written to the page:
<body bgcolor="white">
<p>Paragraph 1</p>
Search WWH ::




Custom Search