JavaScript
Ron Graham
JavaScript is an object-based, loosely-typed, client-side scripting language for use on Web pages.
  • Object-based - as opposed to object-oriented, within JavaScript is a library of predefined objects, and you may use them and their associated methods within user-defined "functions."
  • Loosely-typed - this is to say that the type of data manipulated within a script (whether text or numeric) doesn't have to be specified, except in specific instances. Many JavaScript methods can be applied to text and numbers, unlike in most programming languages, where methods have to work on declared data types.
  • Client-side - the script is invoked by the visitor's Web browser, not by the server hosting the Web page.
  • Scripting - as opposed to programming, this is a language interpreted by the browser, when a visitor opens a Web page containing the script (or, "at run-time"), and is not compiled.
Since JavaScript is interpreted, the way it's interpreted is dependent on browsers and versions of browsers. In fact, Microsoft has developed its own "JScript," so its Internet Explorer supports JScript and most of JavaScript as well. But not all. If you use JavaScript you should be careful to make sure that your visitors can see what you want them to see.

And, since JavaScript is interpreted by the browser, anything a JavaScript function does to your page is not permanent - it "goes away" when the visitor leaves and "starts over" when the visitor returns. You can't use JavaScript to make "permanent" changes to any page on your site. You can't use it to open or to change files.

JavaScript is, however, highly useful in the following areas:

  • Any application that uses date and time
  • Form pre-processing (e.g. checking for valid inputs)
  • Management of images, such as ad rotators
  • Special text features, such as navigation bars
  • Pop-up windows
  • Working with stylesheets to create dynamic HTML effects

[...Status Bar Message active below this window...]

The problem with a status bar message is that it takes over the status bar. Normally, if you move your mouse over an active link, the browser default is for that link's destination to show up in the status bar. Some users hate to have that default lost.

NOTE: Your mileage will vary in terms of how much your site visitors will want these effects. Some find such effects as pop-up windows and status bar scrolling text distracting.

References

Ron's Pokemon Bingo script
Getting Started with JavaScript
webdeveloper.com JavaScript resources
javascripts.com - thousands of free scripts


Examples

Here is a simple example of JavaScript -- it's used on this page to tell readers when the page was last updated:

 Last updated
 <script language="JavaScript">
 <!-- // hide as appropriate
   document.write (document.lastModified);
 // stop hiding -->
 </script>

Following are other simple examples, with captions. These JavaScript functions work on most Web browsers:

JavaScript Clock

Note Pad

Alert Box

[Table of Contents] [Previous] [Next]