1. Technology
Send to a Friend via Email

JavaScript Blog

By

Farewell

Sunday September 4, 2011

After seven years of writing content for this site I have decided that it is time to move on.

Analog Clocks

Saturday September 3, 2011

Old JavaScript never die, they just get rewritten. In between writing new scripts and tutorials, I occasionally revisit old scripts and look into what needs to be done to update them. Some time after first writing them I revisited both my original analog clock script and also the more recently written multi-clock version to see what needed to be done to modernise them. In the case of the multi-clock version it already has most of the code enclosed within objects to minimise interference from other scripts and completely unobtrusive and so I made just a few minor tweaks to the code to make it slightly shorter without changing the way it works at all. The original script underwent somewhat bigger changes as I reworked the code based on some of what is in the multi-clock version to remove the need for the body script and to make it unobtrusive. There is no point in my also amending it to enclose the code in an object because that would just make it the same as the multi-clock version. If you write your own scripts you will need to revisit them occasionally to bring the code more up to date. The biggest problem when you have lots of scripts is to prioritise which ones to update first.

Analog Clocks

Slide Show

Friday September 2, 2011

Let your visitors step through a selection of images one after the other with a JavaScript slideshow. A variation on the mouseover script that will load a succession of images in a "slide show" as your visitor selects the "next" link. They can even go back to the previous image and the entire slideshow wraps around to the first image when they reach the end.

Slide Show

Cycling Banner

Thursday September 1, 2011

Animate your images with JavaScript. You can use JavaScript to replace images on your page at regular intervals. This is useful for when you want to use photos or other images that can't be incorporated into animated gifs.

Cycling Banner

Tbodies and Rows

Wednesday August 31, 2011

The only difference between referencing rows in the thead or tfoot of a table and referencing them in a tbody is that a table can have more than one tbody. In this example we look at how to build two nested loops that will reference every row within each tbody in order to apply a class to every even row in each tbody.

Tbodies and Rows

Table Footer

Tuesday August 30, 2011

The footer of a table is as easy toreference in JavaScript as the table heading is. We could insert a row the same way as we did with the head except referencing tfoot instead of thead or we can simply call deleteRow to delete a specified row (which would also work for deleting heading rows).

Table Footer

Table Heading

Monday August 29, 2011

Adding a heading row to a table is as simple as

Table Heading

Table Caption

Sunday August 28, 2011

The DOM call to update a table caption is very straightforward as you can access it directly once you reference the table rather than having to hunt within the table for it.

Table Caption

Switch Fallthrough

Saturday August 27, 2011

In a JavaScript switch statement when a particular case is run it processes all of the code through to the next break statement. This means that the code may fall through past other case statements. This can lead to complications when you are trying to debug the code and you can't tell whether there is a break statement missing before a case statement. By not allowing cases to fall through and run the code of subsequent cases (except where the cases share all identical code) you can remove this problem without having to make significant changes to the code.

Switch Fallthrough

Optional Function Arguments

Friday August 26, 2011

JavaScript functions can accept a variable number of arguments. JavaScript provides a completely different way of making function arguments optional from the way that most programming languages do it. JavaScript's way gives you the maximum possible flexibility.

Optional Function Arguments

©2014 About.com. All rights reserved.