JavaScript : Create Dynamic Content
Contents ]
Claude Levior

Changing Page Content via a Script

We will now use the write method to generate the text directly in the page instead of displaying it in a message box:

<SCRIPT>
document.write('Good evening');
</SCRIPT>

The text "Good evening" is inserted in the page without the single quotes. Not bad, but we can do a lot better.



Figure 2: A JavaScript can write directly in a page.

It's raining dialogue boxes! With JavaScript you can display all kinds of dialogue boxes. The confirm instruction generates a dialogue box with a confirmation message and two buttons (OK and Cancel). As for the prompt command, this displays a dialogue box with one message and a text field. This will be explored in future workshops.