Ken Ward's New Java Script Tutorial

How to know whether Java Script is working

This page introduces the idea that it easier to learn a programming language when we can 'see' the results of what we are doing. This page also states a requirement of all java script programs.


 
We will start off the tutorial by setting up a program. This will prepare us other work where we continue to use these ideas. The plan is to learn Java Script by using Java Script to teach us Java Script.

You need to know a bit about forms for this lesson. If you need to learn this, then go to the HTML Guide.

Go on, press the button, then:

Now let's look at this code. The code is put in the HEAD of the document, which is a good place to put code generally. Firstly, the code is between two tags as follows:

<script type="text/javascript">

The code goes here

</script>

Like most tags, it has a start tag <script> and an end tag </script> The modern (XHTML) approach is to use:

<script type="text/javascript">

To prevent old browsers from trying to read the code, we put in HTML comment tags:

 

<script type="text/javascript">

<!-- (This is the start comment tag)

The code goes here

(This is the end comment tag)-->

</script>


Finally we put in Java Script comment tags (the forward slashes):

<script type="text/javascript">

<!--//

The code goes here

//-->

</script>

So we can sum up by saying that all Java Script code goes between these tags:

<script type="text/javascript">

<!--//

The code goes here

//-->

</script>

help.gif (2043 bytes)

Let's go on and look at the actual code for the pop-up alert.


[If you need to learn more about HTML visit the HTML Tutorial]

I am always pleased to hear from you.
Send your comments to