Introducing JavaScript

JavaScript has changed a great deal since it was first introduced but many sites still use outdated techniques. There are even lots of JavaScript tutorials on the web that show you how JavaScript should be written so that it can work in Netscape 2 rather than so that it will work in modern browsers. As a result there are many people who are writing what they think is JavaScript but where what they are producing is more suited to the 20th Century than to the 21st.

Beginners should work through all the basic examples prior to moving on to the other examples which cover separate aspects of JavaScript in more detail.

Most of the JavaScript examples here will work in IE5+, Opera7+ and all versions of Firefox, Safari and Chrome. Those commands introduced in ECMAScript5.1 in 2011 have been added (if I have missed any please let me know). Those commands introduced in ECMAScript2015 are currently being added (there are lots of them so it may take some time but then most current browsers do not yet support them all anyway). Where these new commands are not supported by IE8 or IE7 that information is included in the text since those two browsers might still have to many users for you to ignore. So few people using other browsers fail to keep their browser up to date that lack of support in older versions of other browsers will not have any significant affect.

There is a link to jsBin at the bottom right of all the pages. This site provides an easy way to test your JavaScript code online without needing to create an entire web page to run a simple test.

JavaScript Content Security

One consideration regarding web pages and JavaScript whether your page contains any JavaScript or not is the possibility of someone managing to inject JavaScript into your web page before it is delivered to someone else. If you have followed the examples so far you know how to keep your scripts separate from the HTML. This […]

Multi Line Strings

JavaScript doesn’t really need a way to input multi line strings as you can easily concatenate strings together across multiple lines in the one statement. It does have a way to enter multi line strings if you decide you’d rather specify a single string rather than concatenate several smaller ones. Note that multiline strings will […]

window.onload

Most scripts don’t need to wait for the entire web page to load. In most cases simply having the HTML available (as is the case when the script is attached to the bottom of the page) is enough. Even if an image that the script references hasn’t finished loading yet because the JavaScript is interacting […]

Head Scripts

A lot of people still put JavaScript in the head of their page where 99.99% of the time it would allow the page to load faster and the script to run sooner if only they were to move it to the bottom of the page instead. Here we look at the type of script that […]

JavaScript and JScript

When JavaScript was first created it was a proprietary language owned by Netscape. When Microsoft wanted to introduce an equivalent language into Internet Explorer they couldn’t just copy what Netscape had and so they instead introduced their own similar language that they called jScript. The popularity of scripting combined with the incompatibilitis between these two […]

This site is © copyright Stephen Chapman - Felgall Pty Ltd 2011-2016.

Privacy Policy | Terms and Conditions

You are welcome to use any the example JavaScript from this site in the scripts for your site or any that you develop for others but may not use the longer example scripts that contain a copyright notice in any other way without permission.