Introduction to Javascript


JavaScript is an object-based scripting language that can be used inside HTML documents and be interpreted by the browsers Netscape (2.0 and later) and Microsoft Internet Explorer (3.0 and later). Javascript was invented by Netscape but is now standardized under the name of ECMAScript.

JavaScript may also be used to create a server-side application, e.g. with the Netscape Enterprise Server. In that case, Javascript has some additional built-in functions, e.g. to read and write files on the disc of the server machine.


Ressources

Quick indexes to objects, methods and events
Lightweight well organized JavaScript Authoring Guide         (Download it by clicking here)
Alphabetical index on Javascript objects/properties/methods (from the JavaScript Reference)
Prototype program for the handling of form elements
Prototype program for the handling of parameters, windows and documents

Tutorials
JavaScript Guide (tutorial on the client-side JavaScript language)
JavaScript Reference (manual pages for each feature of the entire JavaScript language)
Voodoo's Intro to JavaScript
JavaScript Tutorials & Reference Guides

FAQs, newsgroup, and problems
Compatibility Issues - Tips of the week
Danny Goodman's JavaScript Pages and Compatibility Issues
JavaScript Compatibility with Internet Explorer

Simple examples for each Javascript feature
"The Joy of JavaScript", click on "Scripts"
Ray Daly's javascript demos

Script repositories
ScriptSearch (CGIs and other kinds of scripts in many languages)
FreeCode, Free Programming Source Code
Timothy's JavaScript Examples (bof)
Interface-related JavaScript tips/examples

Miscellaneous simple examples of Javascript features
Combinaison of Web-robots with JavaScript
Animating GIFs
InternetFlora : Send a Bunch

HTML ressources
HTML 4.0 Specification
Local HTML 3.2 Reference Specification
Character entity references in HTML 4.0
Basic HTML relation types
Examples of use of form elements
IBM Web Design Guidelines

WWW ressources
World Wide Web old FAQ
World Wide Web new but small FAQ
The WWW Security FAQ
CNET Glossary
DCE Glossary
Internet Glossary
Computing Dictionary



Tips

To force the reload of an HTML document after its modification, use <shift>Reload, not just Reload. If that still does not work, clear the caches with the "Preferences - Advanced" menu or/and exit from the browser. If you made a bug in a Javascript program (e.g. an infinite loop) and your browser does not let you remove the caches via the menu, you'll have to do it by hand (on Unix, type: rm -r ~/.netscape/cache/*).

When creating hyperlinks, use relative URLs. To refer to the file index.html in a directoty, use the name of this file, do not just put the path of the directory (some Web servers do not understand this abbreviation).



JavaScript and Java

This section is extracted from the first chapter of the JavaScript Guide.

JavaScript and Java are similar in some ways but fundamentally different in others. The JavaScript language resembles Java but does not have Java's static typing and strong type checking. JavaScript supports most Java expression syntax and basic control-flow constructs. In contrast to Java's compile-time system of classes built by declarations, JavaScript supports a runtime system based on a small number of data types representing numeric, Boolean, and string values. JavaScript has a prototype-based object model instead of the more common class-based object model. The prototype-based model provides dynamic inheritance; that is, what is inherited can vary for individual objects. JavaScript also supports functions without any special declarative requirements. Functions can be properties of objects, executing as loosely typed methods.

Java is an object-oriented programming language designed for fast execution and type safety. Type safety means, for instance, that you can't cast a Java integer into an object reference or access private memory by corrupting Java bytecodes. Java's object-oriented model means that programs consist exclusively of classes and their methods. Java's class inheritance and strong typing generally require tightly coupled object hierarchies. These requirements make Java programming more complex than JavaScript authoring.

In contrast, JavaScript descends in spirit from a line of smaller, dynamically typed languages such as HyperTalk and dBASE. These scripting languages offer programming tools to a much wider audience because of their easier syntax, specialized built-in functionality, and minimal requirements for object creation.

JavaScript Java
Code integrated with, and embedded in HTML Applets distinct from HTML (accessed from HTML pages)
Interpreted (not compiled) by client Compiled bytecodes downloaded from server, executed on client
Dynamic binding. Object references checked at runtime Static binding. Object references must exist at compile-time
Object-based. No distinction between types of objects. Properties and methods can be added to any object dynamically Object-oriented. Inheritance through the class hierarchy. Classes and instances cannot have properties or methods added dynamically
Variable data types not declared Variable data types must be declared
Cannot automatically write to hard disk Cannot automatically write to hard disk




Philippe A. MARTIN, Griffith University, School of Information Technology, Australia
E-mail: pm .@. phmartin dot info

URL of this document: http://www.phmartin.info/int3004/javascript/
Last modified: Tue Sep 21 13:43:12 EST 1999