Ken Ward's Java Script Tutorial ...

Doing it with images

Click on the house and see what happens!

On my computer an alert message occurs reminding me to press the browser's back button to return to this page. When I click on OK the index page opens.

Here is the code:

<form action="index.html" method="get">

<p>

<input type="image" src="home.gif" onclick="alert('Don\'t forget to press the back button to return!')" width="72" height="41" />

</p>

</form>

Once again, the code is much the same. We have the

<form action="index.html" method="get">

Which is really HTML. (See form buttons in the HTML Tutorial.) The action of the form is the program you want to run, in this case, the main page.

The next line makes the input type of the form an image:

<input type="image" src="home.gif" onclick="alert('Don\'t forget to press the back button to return!')" width="72" height="41" />

The code for the alert button is the same as we have used in the previous lesson:

onclick="alert('Don\'t forget to press the back button to return!')"

As we have seen above, the image acts the same as the submit button. Pretty neat, isn't it?

Next: Jumping from a Button

 


And for some programming for your brain: check out New Life Course