Now, this is a bit complicated, so I'm not sure how to go about doing this...
I'm looking for a script of somesort that would rotate through an array of banners randomly, without reloading the page. The rotation would be based on a timer. To futher make things complicated, the timed interval between each banner change would be random as well.
Anyone?
Timed Random Banner Rotation
Started by Raldo, Nov 20 2005 09:03 PM
7 replies to this topic
#1
Posted 20 November 2005 - 09:03 PM
#2
Posted 20 November 2005 - 10:00 PM
You will need to use some javascript
This should work:
This should work:
<script language="javascript" type="text/javascript">
var maximum = 2000;
var banners = Array('banner1.gif', 'banner2.gif', 'banner3.gif');
function start () {
var object = document.getElementById('object');
object.src = banners[Math.floor(Math.random() * banners.length)];
setTimeout('start()', Math.floor(Math.random() * maximum));
}
</script>
Replace object with your banners name
Edited by HaloprO, 20 November 2005 - 10:01 PM.
#3
Posted 21 November 2005 - 12:10 AM
Awesome, thanks!
Before I forget, how would I go about making the banners into links as well?
Do I add another array in the same order as the banners to correlate the links?
Before I forget, how would I go about making the banners into links as well?
Do I add another array in the same order as the banners to correlate the links?
#4
Posted 21 November 2005 - 01:49 AM
This would require a bit more work, give me a little time and I can rustle something up
#5
Posted 19 August 2006 - 01:10 PM
I'm looking for a version of this as well but it's a little different.
I'm looking to have a header image change based on the time of day.
Example: Durring the day betweem 7am and 6pm I'd want to have image1.jpg shown in the header.
Durring 6:01 pm and 6:59 am have image2.jpg show in the header.
Is this possible?
I'd be really cool to have it like maybe 10 images rotate. To go say from sunrise to sunset
I'm looking to have a header image change based on the time of day.
Example: Durring the day betweem 7am and 6pm I'd want to have image1.jpg shown in the header.
Durring 6:01 pm and 6:59 am have image2.jpg show in the header.
Is this possible?
I'd be really cool to have it like maybe 10 images rotate. To go say from sunrise to sunset
#6
Posted 19 August 2006 - 01:37 PM
Ooo, that would be hard, since you'd have to base it on the person's local time, but it's possible.
I'm not good at JavaScript so I can't give you anything.
But you would have to find a function in JavaScript to get the user's local time (with a 24 hour clock would be best), then you could use some if statements, such as if(time>7 && time<18) and so on.
I would personally find something like that easier in PHP, except the fact you can't do it without refreshing.
But if you are fine with it not changing while the person it viewing the page (say I was sitting on it at 5:59PM, and haven't refreshed) then I think it would be easier with PHP. Only thing is I'm not very sure on finding a person's time by location unless that person has inputted that information via a form, for example the profile time options on an IPB board.
I'm not good at JavaScript so I can't give you anything.
But you would have to find a function in JavaScript to get the user's local time (with a 24 hour clock would be best), then you could use some if statements, such as if(time>7 && time<18) and so on.
I would personally find something like that easier in PHP, except the fact you can't do it without refreshing.
But if you are fine with it not changing while the person it viewing the page (say I was sitting on it at 5:59PM, and haven't refreshed) then I think it would be easier with PHP. Only thing is I'm not very sure on finding a person's time by location unless that person has inputted that information via a form, for example the profile time options on an IPB board.
#7
Posted 19 August 2006 - 01:46 PM
Demonslay, on Aug 19 2006, 11:37 AM, said:
Ooo, that would be hard, since you'd have to base it on the person's local time, but it's possible.
I'm not good at JavaScript so I can't give you anything.
But you would have to find a function in JavaScript to get the user's local time (with a 24 hour clock would be best), then you could use some if statements, such as if(time>7 && time<18) and so on.
I would personally find something like that easier in PHP, except the fact you can't do it without refreshing.
But if you are fine with it not changing while the person it viewing the page (say I was sitting on it at 5:59PM, and haven't refreshed) then I think it would be easier with PHP. Only thing is I'm not very sure on finding a person's time by location unless that person has inputted that information via a form, for example the profile time options on an IPB board.
I'm not good at JavaScript so I can't give you anything.
But you would have to find a function in JavaScript to get the user's local time (with a 24 hour clock would be best), then you could use some if statements, such as if(time>7 && time<18) and so on.
I would personally find something like that easier in PHP, except the fact you can't do it without refreshing.
But if you are fine with it not changing while the person it viewing the page (say I was sitting on it at 5:59PM, and haven't refreshed) then I think it would be easier with PHP. Only thing is I'm not very sure on finding a person's time by location unless that person has inputted that information via a form, for example the profile time options on an IPB board.
Thanks the for the replay.
I really don't need it to go off the viewers time zone at all. I need to work only on the pacific time zone. So whatever time PST is what matters
Also I would think it would need to be done in php as well.
I just didn't see the need to make a whole new posting pretty much asking for the same thing. I searched and found this thread so I thought I'd ask in here.
Thanks again
#8
Posted 19 August 2006 - 02:39 PM
Well, any ways I can think of would only give the current time on your server, wherever that is located, lol.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
