Click to See Complete Forum and Search --> : Certain-Time Auto-Redirect
MasonMccoy
09-01-2003, 11:32 PM
First off, I'm new here. Now to business: I was wondering how I could make an auto-redirecting webpage, but it has to be specifically designed to work during a specific hour. I attempted to create this manually, but I could not get the javascript to work properly. Of course, the fact that I'm a VB programmer may not help me in javascript; and the fact that I never used javascript before probably doesn't help either...
simpson97
09-02-2003, 04:27 AM
I would use something like this.
<script>
window.onload = init
function init() {
bewitchinghour = 12
now = new Date()
hour = now.getHours()
if(hour == bewitchinghour) {
window.location = "http://www.yourdomain.com/redirectpage.html/"
}
</script>
Hope this helps,
Bob
MasonMccoy
09-02-2003, 09:35 PM
It didn't work for me... -_- Nothing ever works for me... :P
Try this one:
<script type="text/javascript">
function changePage() {
date = new Date();
hour = date.getHours(); //hour is in military time (0-23)
if (hour == 22) {
window.location.href = "http://www.webdevfaqs.com";
}
}
window.onload = changePage;
</script>
MasonMccoy
09-03-2003, 06:50 PM
Thank you. That one worked. I guess maybe the other one didn't work because I didn't know the hour to put or something. ^_^;
You're welcoem. Glad that's what you needed... :)