Background information

Scripting conventions

Some useful scripts:

User Alerts

Page information

Pull-down menus

Random images

Mouseovers

Windows and remotes

Where to go from here



Classes home

HTML Info home

 

Javascript

Jeff Williamson
Northern Virginia Community College
www.nvcc.edu/home/nvwillj/html-graphics/
nvwillj@nvcc.edu


Scripting conventions

A few conventions in Javascript are present in every script.  Knowing them early on makes scripts easier to read.

1. Every script must come between <SCRIPT> tags.  The <SCRIPT> tag may also include attributes for language and version:

<SCRIPT LANGUAGE="JavaScript1.2">

I will skip language and version attributes in these pages just to keep code examples as short and readable as possible.

2. Browsers should ignore data between unknown tags, so non-Javascript enabled browsers should just skip Javascript commands, right?  Nah - they display them.  Or they will - unless - you place your Javascript in HTML comment tags:

<SCRIPT LANGUAGE="JavaScript1.2">
<!--
javascript commands
-->

</SCRIPT>

Which browsers are we talking about here?  According to Tom Negrino and Dori Smith, the list includes

  • Netscape 1x
  • MSIE 3x and earlier
  • AOL 3x and earlier

3. Comments in Javascript can be written two ways:

// precedes single-line comments

/* and */ encloses multi-line comments

Double-slashes are more commonly used than slash-asterisks for comments.  However author/programmer Danny Goodman points out that slash-asterisks are useful for commenting out segments of code in testing.

 

Comments? Questions? Visit the help page

Machine translations of this page into
Spanish, French, German, Italian, and Portugese
are available

Last updated information on updates page