Create a blank Web page from the template you created in the beginners HTML section. You will use this Web page for the next few tutorial topics so make sure the HEAD section is correct. Now add this code inside the BODY tags:
<script type="text/javascript">
alert('Hello new scripter');
</script>
Save the page and load it in a browser. You should get a dialog box appearing.
The TYPE attribute tells the browser this is JavaScript rather than another language. The browser now knows to run what is inside the SCRIPT element through it's JavaScript interpreter.
Now place an HTML paragraph before the SCRIPT element and another afterwards.
Load the page again. Note that the first paragraph appears, then the script shows the alert dialog box and only after you click OK does the second paragraph show. Scripts in the BODY run when the browser gets to them.
Allowing for old browsers
Very old browsers may not understand JavaScript and so anything inside the SCRIPT tags will show as text on the screen. To avoid this it is good practice to enclose the contents as HTML comments:
<script type="text/javascript">
<!--
alert('Hello new scripter');
-->
</script>
An even better way is to put all JavaScript in an external file but that comes later.


