JavaScript

Tuesday April 8, 2025
updated: April 10, 2002

 
Home
Getting Started
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Resources
Credits

 

 


Lesson 1 Example: Using JavaScript

SAMPLE CODE:

<SCRIPT>
<!-- hide code from old browsers
document.writeln ('My first JavaScript.<br>');
document.writeln("This is FUN!<br>");
//end hiding code -->
</SCRIPT>

RESULTS:

My first JavaScript.
This is FUN!

Yawn... this is may not seem all that exciting, but it is an important lesson! You learned:

  • Java code is written between the <SCRIPT> tags
  • Java code should be written between HTML comment tags
  • Java statements end with a semicolon(;)
  • HTML statements (i.e. <BR> ) work the same in Java statements as they do in a HTML document, but they must be placed in the string (within the quotes)
  • It doesn't matter if you use single quotes (')or double quotes ("), the browser reads them the same way.
  • Put the Java statement where you want the text to be in your HTML document

© 2002 Tracy Johnson