
Home
|
 
JAVA SCRIPT
Here are the key things to notice:
- JavaScript usually goes between the </title> tag and
the </head> tag.
- Like HTML, JavaScript is just text that can be typed into a word
processor. It goes right into the HTML that describes your page.
(Although I've only shown JavaScript in the header of the HTML page,
you can also put JavaScript in the body. You'll see an example of this
in the next lesson.)
- The beginning of a bit of JavaScript begins with <script
language="JavaScript">
- Right now, you don't really have to put the language="JavaScript"
element in there because JavaScript is the default script language for
all browsers. However, this could change, so it's a good idea to
include the language element.
- Everything between // and the end of a line is a comment
and will be ignored.
- Comment, comment, comment! A basic rule of good programming style is
that you should always think about the next person who has to look at
your script. It might be a friend, a co-worker, an employer, or it
could be you in three months. The easiest way to make sure you'll
understand your own script in three months is to comment freely and
often. If you want to comment a huge block of text, you can put it
between /* and */ like this:
/* this is
a huge block
of text that I've
commented out */
- alert("better, stronger, faster"); calls up a
simple dialog box with the words "better, stronger, faster"
inside.
- Here's your first piece of JavaScript: the alert method. You'll
learn more about how this line works in the next lesson. For now, you
just need to know that you should end it with a semicolon, and put the
text you want in the alert box between quotes.
- JavaScripts end with the </script> tag.
- No rocket science here. Easy as HTML.

 |