TT281 JavaScript HomePage

Welcome to my site.
As an experienced programmer, new to JavaScript, I demonstrate some of its power, and answer some of my own early questions.

This page explains what JavaScript is, how it works, why and for what it is useful, and then discusses some browser issues.

What is JavaScript?

JavaScript can add functionality to static HTML pages, without the power, expense, and complexity of server-side scripting.
It's a compromise between static and server-side-supported pages, and combined with Cascading Style Sheets (CSS) and HTML, allows writing of DHTML - Dynamic web pages.
Javascript is an interpreted coding language.


JavaScript's code constructs are similar to C and C++, though slightly different from VB:
If you are a VB programmer, you'll need "switch" for "select" and "!=" for "<>"
However: the worst code difference is the test for equality. In Javascript and C, "If (A=B)" assigns B to A, then returns true. To test for equality in JavaScript, you'll need the double-equals: If (A==B)

JavaScript is interpreted by the visitor's chosen browser - and browsers interpret things differently. Rather like Australian-English, English-English and American-English, you think you're talking the same language - but you're not.

The code syntax is the same in any browser, although leniency with syntax errors varies:
Opera and IE accept an array reference of myArray(3); while Netscape insists on the correct myArray[3]

But worse, is the DOM

How does JavaScript work?

JavaScript works by manipulating the Document Object Model (DOM).
This defines the internal structure of an HTML-page: its elements, their properties, attributes and methods, and the events which may be fired. We write JavaScript to this model - but Netscape and MSIE's models differ, and others don't support the whole.
As a programmer used to strict rules for syntax, but once "it works, it works", this will be disorienting to say the least.

But, all is not lost - for a partial solution, hop to Welcome the W3!

return to top

Why and for What can JavaScript be ?

Javascript can add to presentation and functionality.
However, it is the "icing on the cake", not the cake. Many users' browsers don't support JavaScript, or users disable it, from security-fears, or irritation with pop-up windows (powered by JS.)
No page navigation, content, nor anything vital should depend on Javascript; it can add a lot to a page, but must not be critical.

Some common usages are:

return to top

Browsers Supported

Cross-Browser incompatibility will be the biggest problem for an experienced programmer.

This site has been tested in IE (4, 5 and 6), Netscape (4, 6 and 7), Opera (5, 6 and 7), and the text-only browser Lynx.

Navigation and content-accessibiltiy is possible to all (non-demonstration) pages, although older browsers generate a plethora of syntax errors. Demonstrations work in all the newer browsers.

If JavaScript is disabled, every page carries a message and instructions for navigation around the site:
<noscript>JavaScript is not enabled. Please......</noscript>

I do not check for frames support; nor do I support Netscape 4 browsers with code.

I do ensure page-accessibility for text-only browsers, for users without the option of modern windows-based browsers (which NS4 die-hards reject).
Navigation around the whole site is possible using the text-only Lynx browser.

return to top

Browser Checking

According to the navigator object of the DOM, you are currently viewing this site in:

According to Browser-detection code (from http://www.xs4all.nl) you are currently viewing this site in:

Because of this difficulty, the site does not check for a specific browser by name during code, but uses feature-testing instead:

  1. To ensure that the DOM API is supported:
    if (document.getElementById)
     {

  2. To establish which control issued an event (during validation): //MSIE or NS DOM?
    var myField=callingEvent?callingEvent.target:event.srcElement;

  3. An example of incompatibilities can be seen by viewing the following page in IE and then in Netscape:
    Demo:Check colours

return to top


I have pushed my word-allocation to the limit (547, excluding links and greyed code-text) already

The World Wide Web consortium

The "World Wide Web consortium" is a non-profit organisation of independent web-professionals, issuing recommendations (often termed 'standards') to which they encourage browser-writers and page-authors to adhere.
If everyone followed these standards, then any web-author could write pages that worked in any browser. The user would have a free choice of browser, confident that all apges would work as well in that as in any other - and the web-author's job would be easier.

return to top



There should be a homepage, the ‘TT281 JavaScript Homepage’.
This homepage should allow access to the other pages and itself contain a concise text covering:

The homepage should also

The homepage content should be concise and clear.
There should be no more than 500 words