C & G web

JavaScript

JavaScript is a comparatively easy-to-use scripting language that can be embedded in your web pages. It can enhance the dynamic and interactive features of your page by allowing you to perform calculations, check forms, write interactive games, add special effects, customise graphics selections, create security passwords and more.

Learning Objectives

  1. To provide learners with the history behind the development of Javascript.
  2. To be aware of some of the advantages and disadvantages of using Javascript.
  3. To show clearly the differences between Javascript and Java.
  4. To show what kind of things JavaScript can be used for.

Requirements: A JavaScript compatible browser. (Netscape Navigator 2.0 or greater and Microsoft Internet Explorer 3.0 or greater)

A word about Browser support

At the moment JavaScript is supported by a good range of browsers. Netscape Navigator 2.0 and greater and Microsoft Internet Explorer 3.0 and greater are, between them, by far the most used browsers and they all support JavaScript. Unfortunately their implementation varies.

Efforts are being made to standardise browser scripting with the ECMA script standard. The problem is that both Netscape and Microsoft claim that their browsers conform to the standard, they just do it in different ways.

This module aims to convey the fundamentals of the JavaScript language and to do that it needs to avoid getting side-tracked by implementation issues. To handle these issues you first need a good understanding of the JavaScript language. For now just be aware that writing JavaScript code for more than one browser is not a straightforward matter.

So the reason that the word Gateway is used is because CGI defines the gateway between the server and the helper programs that reside on the server.

History

Before JavaScript
The HTML language, used to create pages for the World Wide Web, was originally designed to produce plain, static documents for academic and scientific use. Originally the only Web browsers were text based and HTML was sufficient.

Mosaic was the first graphical browser. When Mosaic was released the concept of what the Web could do was dramatically changed. Developers and users both started demanding more enhancements to what a browser could do.

Designers wanted control over colour, tables and images. Businesses wanted intelligent forms and secure pages. Everybody wanted the new buzzword, "interactivity".

JavaScript is Born
JavaScript was created by Netscape in response to user and developer demand and was initially called LiveScript. It was planned as a feature for Netscape Navigator 2.0 released in January 1996. The idea was to allow Web page designers to augment their Web pages with the much touted "interactivity".

At the same time interest was building in a language originally designed for household appliances, such as microwaves and washing machines, and which was now being used on the Web. Java, developed by Sun Microsystems.

In a act of mutual back scratching, unusual in Internet technology development, Netscape decided to support Java in Navigator 2.0 and, in exchange, Sun decided to help Netscape re-design LiveScript and re-name it JavaScript. The prime creators of JavaScript were Brendan Eich from Netscape and Bill Joy from Sun.

What's the difference between JavaScript and Java?

Java is a compiled programming language (technically it is semi-compiled but we won't go into that). It is powerful enough to write major applications and these applications can be embedded within a web page as Applets. You cannot see the Java code of an Applet by looking at the source of the HTML page.

Java is cross-platform, meaning that the same Java program can run on any hardware platform (on IBM, Mac, and UNIX computers for example). Java is not an easy language for non-programmers.

In contrast to Java, JavaScript is an easy-to-use scripting language. JavaScript has an easier learning curve than Java and can be used to add interactivity to Web pages with little effort.

JavaScript is an interpreted language. In the case of JavaScript this means that it has to run within a browser. It is written directly into a page of HTML. If you view the source of a JavaScript enhanced page of HTML you will be able to read (and "borrow") the JavaScript code. On the negative side, JavaScript is not as powerful as Java.

Java and JavaScript can work together
One of the important aspects of Sun and Netscape's co-operation is the commitment to make the languages work together. They share a similar syntax and control structure that make it easier for programmers to write code for either language. But more important, a JavaScript enhanced HTML page will be able to communicate with a Java Applet embedded within the page. JavaScript can also talk to some plug-ins such as RealAudio and so control sound.

Another aspect of this sharing takes place not in the browser, but in the server. Some servers support JavaScript so you can write programs that can handle data there as well. This is a specialised use of JavaScript that most JavaScript programmers do not get involved in.

Previous page...

Back to Top of Page

Computeach International Ltd

Christopher Ward London Limited

Christopher Ward London Limited