Your First JavaScript
Choose your editor
All your JavaScript Code needs to be entered and edited in a plain text
or html editor. You can not use the editor in Netscape Gold as it will
just put your JavaScript in as "displayable text".
Enter The Basic HTML Tags of any document
In The Body Section Add The Following JavaScript Lines
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from other browsers
document.write("Hello World!");
// Stop hiding from browsers -->
</SCRIPT>
Notes:
- The JavaScript Appears Between the <SCRIPT> and </SCRIPT>
Tags
- The <!-- and --> tells the html viewer that the text (ie. JavaScript)
between them are just "comments", thus it does not display them.
- // indicates the rest of the line is an JavaScript comment
- ; denotes the end of a statement, just like in C, C++, and Pascal
- document denotes the default html window
- .write is the method to write text out to an object, such as a window
Save the file to an html document
Open the file Netscape
That's It!
See It In Action
Back