It's Sean!

UK freelance journalist, author
and writer 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:

Books by Sean McManus

Scratch Programming in Easy Steps

Scratch Programming in Easy Steps

Raspberry Pi For Dummies

Raspberry Pi For Dummies

Learn to program with the Scratch programming language, widely used in schools and colleges.

Set up your Pi, master Linux, learn Scratch and Python, and create your own electronics projects.

Coder Academy

Coder Academy

Cool Scratch Projects in Easy Steps

Cool Scratch Projects in Easy Steps

Learn to make games and other programs in Scratch 2.0, and make a web page in HTML, with this highly interactive book for 7-10 year olds.

Discover how to make 3D games, create mazes, build a drum machine, make a game with cartoon animals and more!

More books

Recommended articles

Stylised coloured photo of a synth

Discover my music and home recording articles

Interested in starting home recording? Follow me as I start recording, using instruments such as the Novation MiniNova and Korg Kaossilator, and share my synth and sample-based music online.

Scratch cat and rainbow circle

10-block demos for Scratch programming

Lots of people of all ages are learning to program with Scratch. Discover some useful tricks and techniques in my 10-block Scratch demos, including special effects you can drop into your games.

Paper Raspberry Pi case

Download free book chapters and more!

Download a free case for your Raspberry Pi, and free chapters from my books about the Raspberry Pi, Scratch, web design and more!

©Sean McManus. www.sean.co.uk.