HTML Markup | JavaScript | Java | Computer Sci | Home & Links
JR's HomePage | Updates | Site Map | Page Bottom
Why JavaScript | Cautions | JR's Programming Notes
Conventions and Tools | Readings and Samples

JavaScript Authoring Info

JavaScript (aka ECMAScript) is an easy way to make your website visually attractive to clients and other viewers by adding interactivity and dynamics to HTML pages. This page explains why one would use JavaScript in their HTML website design. It also has links to JavaScript tools, readings and samples for those who prefer ready-to-run effects. And finally for those who prefer to roll their own there are my programming notes, some introductory tutorials, small projects, larger projects and form projects pages.

Why Use JavaScript

Why should a webpage author use JavaScript in addition to HTML?

Javascript adds user interactivity
Javascript enhances visual displays
JavaScript allows many page effects
Javascript allows client-side user form validation
Javascript provides seamless integration with user plug-ins
Javascript allows access to some system information

Here are just a few of the many effects that you may want to consider adding to your webpage.

Cautionary Notes

As with any software there are flaws that are only discovered after release and are resolved as they are reported. Just be aware that careful design and thorough testing are needed to make sure your project works for others as well!

Language Design Issues

Because JavaScript uses a high-end approach to security (leaving lapses in the domain of the browser) there are some applications that it is not appropriate for:

Language Implementation Issues

Although JavaScript is easy to understand and to write, there are several reasons rigorous testing is required.

WARNING: Programmers must Test! Test! Test! every JavaScript on several browsers to make sure expectations are met.

JR's Programming Notes

JavaScript is a scripted language which is object oriented, event-driven, and platform independent. Each of these modern concepts in programming methodology are easier to work with in 'new' languages rather than being bolted on to older ones. And the syntax is similar to that of C and Java. This makes JavaScript a 'good' choice for learning as a first programming language.

What other reasons are there for learning to program in JavaScript:

I have prepared a series of introductory tutorials on JavaScript programming. The first few have some short demos that do interesting things. Those who only cut and paste code may find something useful while cruising through these tutorials. Give it a try!

NOTE: Quite often user input is through the forms object and output is through the document object. A thorough knowledge of these two objects is very important for your programming success.

Conventions and Tools

Javascript code should always be written to the ECMA-262 - Edition 3 standard. In addition writing code to standard conventions helps avoid many common programming issues. One of the best ways of checking your work is to use jsLint. Just cut and paste your script into the input box and press the jsLint button. Either you will get an 'ok' message or an easy to interpret message including a line number on any problem. Code that checks out ok with jsLint will be less likely to be quirky in any of the modern browsers.

Every programmer builds his own personal toolbox of utilities. For JavaScript this toolbox must include current versions of the mainline browsers: FireFox, Opera, Safari and MSIE. Amaya is also a handy tool to have as it spots HTML code validation problems which hide JavaScript bugs. The editor of choice is TextPad as you can customize it with macros for fast programming as well as view the results using each of your browsers without leaving the editor.

Readings and Samples

Many still use books to learn in an effective way. One good resource is JavaScript - The Definitive Guide, Flanagan, O'Reilly [5th edition - 2006]. Manuals do not make for easy learning but are required for the nitty gritty details to make things work. Here are a few:

JavaScript is capable of producing very useful programs such as:

Why should you create code to do something if someone else already has done it? The following sites may already have the functions you want and probably many more that you didn't even think about. Spend some quality time trolling for ideas!

CAUTION #1: Most scripts offered by these sites are not conformant code. Be prepared to spend some time with a validator. Common mistakes are the use of language="JavaScript" instead of type="text/javascript" and not escaping the forward slash with a backslash (eg. </p> instead of <\/p>) within HTML closure tags.

CAUTION #2: Some examples work with only one or two browsers. Spend some time testing with a variety of browsers including all major engines (ie. Firefox. Opera, Safari and MSIE/SlimBrowser).

CAUTION #3: JavaScripts that bring up new windows are not compatible with Ad Busting software. Take some time to test your scripts in various environments.

CAUTION #4: JavaScripts that bring up new windows are not always compatible with frameset based pages. This may explain why a published script may not be working for you.


JR's HomePage | Comments [jsintro.htm:2009 09 28]