Go Back   SitePoint Forums > Forum Index > Program Your Site > JavaScript
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Nov 28, 2006, 15:44   #1
Raskolnikov
SitePoint Guru
 
Raskolnikov's Avatar
 
Join Date: Jul 2003
Location: USA
Posts: 604
Yes, another random rotating banner ad question.

Okay,

this is more of a feasibility study right now. I have a list of 3 companies in a MySql db. Each company has its own banner ad.

I would like to have the three banners randomly rotate at an incriment of 5 seconds.

the thing that really screws this up is that I need each banner to be clickable to its respective link (generated from the db along with the banner).

is this even possible with JS? I know that i can make 5 second rotating images. and i know i can make a random image/url on page load. but is it possible to merge the two?

I am thinking that with JS it probably is not possible since the url would have to change with each graphic rotation. secondly i don't think i can easily connect to a db using JS.

I have considered Flash ActionScript, but have never really used it, and would hate to blow alot of time to learn a new language just for on little banner rotator.

any ideas?
Raskolnikov is offline   Reply With Quote
Old Nov 28, 2006, 17:02   #2
Raffles
Tool
silver trophybronze trophy
SitePoint Award Recipient
 
Raffles's Avatar
 
Join Date: Sep 2005
Location: Cambridge, UK
Posts: 3,804
It's certainly possible. You just change the href attribute (linkvar.setAttribute('href','hrefarray[i]')) of the banner link with every rotation along with the img src (imgvar.setAttribute('src','srcarray[i]')). You then just randomise i every 5 seconds.

You would probably need to put the three links in an array and the three image srcs in another array (keeping the indexes parallel) and then randomising the indexes with each rotation. Though I don't see much point in it being random if you only have three.
Raffles is online now   Reply With Quote
Old Nov 29, 2006, 08:35   #3
Raskolnikov
SitePoint Guru
 
Raskolnikov's Avatar
 
Join Date: Jul 2003
Location: USA
Posts: 604
good info raff....

I'll give 'er the ol college try. Ultimately there will be more than three, but for now in the testing phase i keep it relitively small.

Thanks
R
Raskolnikov is offline   Reply With Quote
Old Nov 29, 2006, 14:13   #4
Raskolnikov
SitePoint Guru
 
Raskolnikov's Avatar
 
Join Date: Jul 2003
Location: USA
Posts: 604
So i got this thing to work, however, it works in IE and not in Firefox.

does firefox have issues processing onLoad commands (specifically setTimeout) within img tags?

The banner displays in Firefox, but does not rotate. works fine in IE.

R
Raskolnikov is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 16:44.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved