[Javascript] Banner Ad scripts

Tim Makins spindrift at oceanfree.net
Fri Mar 19 05:39:36 CST 2004


Hi Paul - thanks for your comments - I will investigate further. I don't
think I will go the  (2) route - those things annoy me no end, as well as
continuing to try and work when the page has been saved for viewing offline.

I like the array idea, but to keep things simple, I could pre-prepare a
random list of numbers, then use that list to step through the array.

By the way, I'm not a big fan of advertising either, but if it pays for
bread, beer, and server bills, it might be useful. I have just come up with
an idea for a site that I think will put lots of hits, so want to do things
right. I see Google do their own banner providing service too, text based,
that pays for clicks. Has anyone used that ? I might combine it with a
separate banner ad, and see how it goes.

Tim in Ireland.

----- Original Message ----- 
From: "Paul Novitski" <paul at dandemutande.org>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Wednesday, March 17, 2004 10:37 PM
Subject: Re: [Javascript] Banner Ad scripts


Tim,

Allergic as I am to advertising, how loathe I am to aid in its
proliferation!  However, the basic technology can be used for Good as well
as Evil; I leave the choice to you, O Grasshopper.

In addition to what Håkan says generally about the process, I would add
only a few comments on two possible approaches:

1) When the page is rendered, a single item (image & link) appears and
remains fixed for the life of the page.  Each time the page is revisited,
the item changes randomly or in rotation.

2) The page contains an item that changes every N seconds, either randomly
or in rotation.

Approach 1) can be handled either server-side or client-side by selecting
from a list of optional items when the page is built.  Approach 2) is best
done client-side to avoid a superabundance of network traffic.

I would group the options in an array.  Rotating in sequence means keeping
a record of the last element selected, say either in the visitor's cookie
(to create a per-user rotation) or in a master file on the server (for a
site-wide rotation).

You probably know how to select randomly from a list; the approach I
generally use is to multiply the number of items in the list by a random
number (that being a value between 0 and 1) and take the closest integer of
the result.  One caveat: the usual random numbers we see never equal zero
or one but merely approach them, and you want to make sure you include the
first & last items in the list.  Because we know that the Javascript array
begins indexing with zero and ends with length-1, we can use the Javascript
function Math.floor() that neatly returns the integer less than or equal to
the input value:

         var iItem = Math.floor(Math.random() * aItems.length);
         DoSomething(aItems[iItem]);

Then of course you can use array values to set the src property for an
image and the href & title properties for an anchor tag.

Paul


At 05:12 AM 3/17/2004, you wrote:
>Does anyone have any advice for good banner-advert cyling scripts -
>basically, I want to set up a rotating series of banner ads on a new
>website, but haven't done this before. Any comments, or recommendations ?
>
>Tim in Ireland.
>
>
>PS Happy St.Patricks Day !!!
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript


_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list