Ken Ward's Java Script Tutorial ...


Click on the button below and you will see an example of an alert.

Let's look at its code:

< form action="">
< p >< input type=" button " value=" Hello Button ... " onclick=" alert('Hello');return true " /> < >


(If you want to learn more about forms, click here) The first thing you should note is that if you copy the above code to an HTML page, you will have an alert button. Why not do this now? You can change the 'Hello' in the onclick="alert('Hello'); return true" bit and you will get a different message.

If you change the value, then the button will have a different label. If your button doesn't say 'Hello', then it might not be right to call it 'Hello Button'!

What happens if you leave out the 'return true' bit? Why not scribble it out and see! The next button, long and snaky, hasn't got a 'return true' bit. Press it and see what happens?

On my computer and with IE4, it still says 'Hello'.

What have you learned?


Next: Doing it without a button