web space | free website | Web Hosting | Free Website Submission | shopping cart | php hosting
Second Lesson

There are other ways to write Hello World. For instance you can put the function into a button.
Within the BODY section enter:

<INPUT TYPE = Button VALUE = "Click Me" OnClick = "document.write('Hello World')">

This produces (If you click the button you need to use your browser's Go to last website to get back here):

You can see that the code is within the button "OnClick = "document.write('Hello World')"

The OnClick statement is an event that is an option for buttons (as well as other things). Also since the double quotes is used to surround the document.write() part, you need to put the 'Hello World' in single quotes (this is the key next to ; and not the key next to 1).

Using Pop-Ups


Pop-Up messages (or alert messages) are good to make sure users enter information properly or give them feedback in other ways. The syntax for Pop-Ups are pretty simple. alert("Incorrect Syntax") For example you can put this into a button as well.

Within the BODY section enter:
<INPUT TYPE = Button VALUE = "Click Me" OnClick = "alert('Incorrect Syntax')">

This produces:

JavaScript Tutorial Home
Lesson 1 Lesson 2 Lesson 3 Lesson 4 Lesson 5 Lesson 6 Lesson 7 Lesson 8 Lesson 9 Lesson 10 Lesson 11 Lesson 12 Lesson 13 Lesson 14 Lesson 15 Lesson 16 Lesson 17 Lesson 18 Lesson 19 Lesson 20

Useful Links

Contact Webmaster