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 ECMAScript 5 in 2011 are being added to the site where they are supported by the latest version of all popular browsers. 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.

A few examples of what we can expect from EcmaScript 6 are also included in their own section so you can see the direction that JavaScript is moving in - even though it will probably be quite a while before we can use those commands.

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.

localStorage and sessionStorage

There are two limitations with cookies – one is that they are generally limited to 4k in total size and secondly they need to be passed back and forth to the server in the HTTP headers. There are many instances where you may need to store more data thanwill fit in a cookie and where […]

Read Single Cookie

Not all web pages need to access all of the cookies that they have access to. Where there are lots of cookies available to the page and the page only needs to read one or two then a different approach to reading the cookies may be more appropriate. Instead of extracting all the cookies into […]

Updating Cookies

When we looked at replacing cookies we were not concerned with what value the cookie may have already had. Where we need the original value in the cookie in order to update that value in setting the new value when we replace the cookie a more complicated approach is required since we need to first […]

Reading All Cookies

After a week of considering all the different variations on writing cookies we can at last move on to how to read them back into our script. Because of the way that cookies are passed to and from the server in the HTTP headers that precede the web page content we do not actually need […]

Deleting A Cookie

Something that you probably wouldn’t think is directly related to writing a cookie at all is how to delete a cookie but paradoxically you delete a cookie by replacing the existing cookie with a new cookie with an expiry date in the past.

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

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.