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

09-13-2008, 05:03 PM

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?


Philip M
09-13-2008, 05: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";
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

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

Thank you very much!

09-14-2008, 02: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/page3.html', 'http://yoursite.com/page4.html',
'http://yoursite.com/page6.html', 'http://yoursite.com/page7.html',
'http://yoursite.com/page9.html', 'http://yoursite.com/page10.html',
'http://yoursite.com/page12.html', 'http://yoursite.com/page14.html',
'http://yoursite.com/page15.html', 'http://yoursite.com/page16.html',
'http://yoursite.com/page18.html', 'http://yoursite.com/page19.html',
'http://yoursite.com/page21.html', 'http://yoursite.com/page22.html',

function switchPage() {
var now = new Date();
var hh = now.getHours();
window.location = sites[hh];