Next page | Contents page |

Client JavaScript

Introduction to this section

This course focusses on JavaScript as a programming language, not necessarily having anything to do with the Internet. We have used simple HTML pages as convenient containers for our programs and nothing more. We have so far covered "Core JavaScript" with just a little help from the HTML environment for input and output.

It is not the intention to go on and explain fully how to set up web sites but the HTML framework we are using does provide several useful things for our JavaScript programs and so we will go on to cover some of these, including the following topics.

As of July 2017 these pages are still being written. Please look again soon.

Client JavaScript

JavaScript was designed to be used in various environments but the most common use is within a web browser. For the purposes of this course that has been most useful anyway because everyone has a browser of some kind. We have been using HTML pages as disc files to contain our programs but more usually of course such pages would come from a web server. In that case we talk of a server-client relationship, the client being the user's PC (or tablet, smart phone, etc). JavaScript can be used on servers but this course concentrates on the client side.

Scripting on the client originated in order to make web pages dynamic, with the kinds of output and user input we have already seen. When this was all new the buzz-phrase was DHTML (Dynamic HTML) but that was never really the name of a standard and it was implemented differently in different browsers - a nightmare for developers. We used to have to detect which version of which browser was being used and on what kind of machine (or operating system: Windows? Linux? MacOS?) and provide different code depending on what was found. That can still be done but it is no longer necessary. There are better ways of providing alternatives if certain functionality is not available.

The Document Object Model

The World Wide Web Consortium (W3C) created a standard Document Object Model (DOM) to define the structure of a web page in such a way that JavaScript programs could access components of the page, to find their values and to modify them. In recent years browser makers have recognised the usefulness of standards and have converged on the one standard. As the standard develops to include new features the browsers try to keep up but with an inevitable time lag.

Many of the features of the original DHTML are no longer relevant and so we will ignore them. Just be aware that there are many other ways of doing things, owing to the complicated history of the DOM. If you look at other people's scripts, some of which may have been around for many years, you will see "archaic" code which still works because browsers still support many of the old ways.

If you look at the W3C DOM technical reports page you will see that the standard is evolving through "levels". The current standard is Level 3, released in 2004, which all browsers aim to support. W3C is working on Level 4 for some future release. It is possible to determine by JavaScript which level of DOM a particular browser supports.

Next page | Contents page |