JavaScript : Create Dynamic Content
Contents ]
Claude Levior

A Welcome Message in a Box

You already learnt about the <SCRIPT> and </SCRIPT> tags in our first unit. They will now be part of our toolbox. Our first script will be activated as soon as the page is loaded to display Hello in a dialogue box. Enough talk, now for some action! Place the following lines anywhere in the body of your page (between the <BODY> and </BODY> tags).

<SCRIPT>
alert('Hello');
</SCRIPT>

The semi-colon terminates the one line of code in our little program.

Syntax. The semi-colon is optional. However, your code will be more readable if you adopt the good habit of using it.

Open the page in your favourite browser. Eureka! Just click on OK to close the dialogue box.



Figure 1: Use the alert instruction to display a dialogue box.