JavaScript

Posts about the client side scripting language JavaScript.

JavaScript Scrolling Box Marquee Replacement

Tuesday, January 29, 2008 - 14:34

Having a Marquee on a web page is a nightmare from an XHTML validation point of view, so here is a neat function that will produce the same effect as a vertical scrolling marquee, that passes XHTML validation, and built entirely from JavaScript and CSS.

Vertical Scrolling

Take the following HTML code. Don't worry about reading it. It is just 7 p tags (2 of which act as spacers) contained within a div tag.

Category: 

Some Useful Maths Functions In JavaScript

Monday, January 14, 2008 - 11:16

All of the maths functions in JavaScript are kept in a handy object called Math, which contains a number of different functions.

To get the absolute value of a number use the abs() function.

Math.abs(3.14159265) // returns 3.14159265

Rounding a number is done by either the round() function to round to the nearest integer, the ceil() function to round up to the nearest integer and the floor() function to round down to the nearest integer.

Category: 

Multiple Google Analytics On Same Page

Thursday, January 10, 2008 - 10:56

To set up multiple Google Analytics tags on the same page you need to use the _uff = false; command in between the unchinTracker() calls to reset the tracker for the next account. The urchinTracker() function will send information on the page visit off to Google Analytics.

Category: 

Postponing Code Running In JavaScript

Friday, January 4, 2008 - 20:54

Creating user interfaces in JavaScript can sometimes lead to a problem, especially when the interface used AJAX to load data from the server. As many actions will be event driven by the user you can find that when a user triggers lots of events all at once the browser will send out lots of AJAX requests all at once. This can easily cause bandwidth issues but can also lead to the user getting confused while they patiently await the browser to settle down and let them get on with things.

Category: 

For Loop Debugging In JavaScript

Thursday, January 3, 2008 - 11:51

The for loop in JavaScript can be used to iterate through all items in an array or properties of an object. This makes looping through any object or array very easy. As in the following example that printing out all items in an array.

Category: