FORUMS: list search recent posts

detect and redirect based on time

COW Forums : Web Design

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
rik wederstrandt
detect and redirect based on time
on Dec 31, 2007 at 5:20:05 pm

I have an index.html. This page redirects based on time of day. I would like it to redirect as follows
6am-9am=morning.html
9am-8pm=day.html
8pm-6am=night.html
the night and the day function fine but when it is time for the morning to redirect it defaults to the day.html. Have i done something wrong in this code. Any help would be greatly appreciated.


function ampmRedirect(dayURL, nightURL) {
var currentTime = new Date();
var currentHour = currentTime.getHours();


if ((currentHour < 6) || (currentHour > 20)) {
window.location.href = "night.html";
} else if (currentHour >=9 || currentHour <17) {
window.location.href = "day.html";
} else {
window.location.href = "morning.html";
}
}
// -->

BODY onLoad="ampmRedirect('morning.html','day.html','eve.html','night.html')"">

Thanks Rik


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]