/    Sign up×
Community /Pin to ProfileBookmark

ad slideshow rotate upon page load

Hi All hoping I can find help here!

I am building a site with ads that I want to rotate positions (this way I can keep it fair for advertisers) upon refreshing the page, searching through the site, or each time the user visits.
basically I want it to look like the ad at the top of this page [url]http://www.nystatemls.com/[/url] except I want it to rotate through three (or more ads)
my site is [url]http://albanyinaction.org/[/url] and the ads are off to the right.
I assume this is just a simple javascript slideshow tweaked a bit but can’t figure it out.

any ideas?
thanks
Spack

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERSep 13.2010 — You might note how I modified the code in post #2

of this thread: http://www.webdeveloper.com/forum/showthread.php?t=235601

You should be able to expand on that to display 3 or more images on your site.

Good Luck!
Copy linkTweet thisAlerts:
@spackletoothauthorSep 14.2010 — thanks for the feedback, it looks like a useful thread. [I]but[/I] any idea of how I could make it so it's not random? and the challenge is going to be making sure that the three different positions are rotating through at different rates... I figure that it's going to follow a images++ type of code...

position 1: sponsor1.jpg

position 2: sponsor2.jpg

position 3: sponsor3.jpg

then upon refresh

position 1: sponsor2.jpg

position 2: sponsor3.jpg

position 3: sponsor1.jpg

then upon refresh

position 1: sponsor3.jpg

position 2: sponsor1.jpg

position 3: sponsor2.jpg

make sense?
Copy linkTweet thisAlerts:
@JMRKERSep 14.2010 — For the first part, remove the randInt() function and call within the onload region.

Second part is confusing me.

Do you want all three images show when refreshed, or just one at a time?

You could save ad pointer variable that increments using a modulo function.

Save the current first entry in a cookie and increment it when loading or refreshing the page.

For example:
<i>
</i>var AdPointer = 0;
function IncAdPointer() {
AdPointer = ((AdPointer+1) % 3);
// save value in cookie to be used with loading or refresh actions
}

Above code works nicely with one image.

Should be easy to modify for 3 (or more) images.
×

Success!

Help @spackletooth spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...