...

View Full Version : Want visitors to see different page depending on time of day...



kopertone1
09-13-2008, 04:03 PM
Hey,

I was looking for a way to have visitors see two different pages. One page that would display a day time page (during the day). Then at night I want it to automatically redirect to a night time version.

The time would be based on the local computers clock.

Any one have any ideas or now of a script?

Thanks!

Philip M
09-13-2008, 04:23 PM
<body onload = "switchPage()">

<script type = "text/javascript">
function switchPage() {
now = new Date();
hh = now.getHours();
if (hh > 5 && hh < 18) { // from 0600 to 1759
window.location = "http://yoursite.com/page1.html";
}
else { // from 1800 to 0559
window.location = "http://yoursite.com/page2.html";
}
}
</script>
Obviously you can change the hours to suit.

The road to happiness is not getting what you want, but wanting what you get. - Philip M

kopertone1
09-13-2008, 04:31 PM
I'll give it a go...

Thank you very much!

jmrker
09-14-2008, 01:17 AM
As a variation of the earlier post, you could also redirect hourly: :D


<body onload = "switchPage()">

<script type = "text/javascript">
var sites = [
'http://yoursite.com/page0.html', 'http://yoursite.com/page1.html',
'http://yoursite.com/page2.html',
'http://yoursite.com/page3.html', 'http://yoursite.com/page4.html',
'http://yoursite.com/page5.html',
'http://yoursite.com/page6.html', 'http://yoursite.com/page7.html',
'http://yoursite.com/page8.html',
'http://yoursite.com/page9.html', 'http://yoursite.com/page10.html',
'http://yoursite.com/page11.html',
'http://yoursite.com/page12.html', 'http://yoursite.com/page14.html',
'http://yoursite.com/page14.html',
'http://yoursite.com/page15.html', 'http://yoursite.com/page16.html',
'http://yoursite.com/page17.html',
'http://yoursite.com/page18.html', 'http://yoursite.com/page19.html',
'http://yoursite.com/page20.html',
'http://yoursite.com/page21.html', 'http://yoursite.com/page22.html',
'http://yoursite.com/page23.html'
]

function switchPage() {
var now = new Date();
var hh = now.getHours();
window.location = sites[hh];
}
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum