It's Sean!

UK freelance journalist, author
and copywriter Sean McManus

Printed from www.sean.co.uk. © Sean McManus.
Home > Articles > Webmaster resources > Javascript Toolkit > Javascript examples > Adverts

The Javascript smart marketing toolkit

Javascript banner ad cycling toolkit

Using the toolkit, it is possible for you to manage your banner adverts and cookies without having to do any programming yourself. All the data fed through the toolkit is stored in a single cookie called 'bannercookie'.

Once you've edited your banner details into the toolkit (see the remarks in the toolkit code for where to do this), you can use one line of Javascript to have your adverts automatically cycled:

output_banner(least_seen());

Here's an example of this code in action. When you revisit this page, you'll see the next ad in this slot. I've also added the banner code at the foot of the other demonstration pages. Whatever order you visit the demonstration pages in, the adverts will cycle in the right order.

Table explaining banner advert functions of the toolkit
function what it does
set_up() The set_up() routine must be run when the page loads.
output_banner(number) After the hard work of editing the set_up() routine, all you need to do to display a banner advert (and automatically keep track of how many times it's been displayed) is to call this routine with the appropriate banner number.
least_seen() This will tell you the number of the banner advert that has been shown the fewest times.
banner_swap(oldbannernumber,newbannernumber) Use this routine to swap a banner once you have already output it. The last banner of number oldbannernumber to appear on screen will be replaced with banner newbannernumber
banner_replace(filename, link, bannernumber) Use this to change the banner allocated to a particular slot by assigning a new filename for the image, new link address and an existing bannernumber.

Navigating the toolkit: