View Full Version : From today's links to other htmlpages after days.

08-19-2004, 10:36 AM
I am trying to master (?) JavaScript and I am a little bit in trouble now.
On the "index.html" are a lot of links, each one leading to another html.page.
How can I change (or redirect) to another html.page after a well defined period of time (ex. 5 or 12 days from now on).
So people go automatically to another htmlpage (to see different content) from that specific date.

I tried with the expression <body onLoad="fctionChange">.
Trying to write this "fctionChange" I don't know how to handle the date of today and the date in the future.
I guess it has something to do with " if .... else", but I'ts a hard time to make it work.
Maybe I am wrong and it has nothing to do with the "onLoad"event.

Can anyone of you please help me or give me some helpfull tips.
Thanks a lot.

I posted this thread earlier, but maybe I was not clear enough.
So I tried to explain it in another way.
I hope this time it will work.

Willy Duitt
08-19-2004, 11:23 AM
To retain continuity, your other thread can be found here (http://www.codingforums.com/showthread.php?t=43484) which BTW, it would have been more appropriate to follow up on your original thread rather than starting another....

And I'm afraid you are still not being clear enough...
Providing an onLoad="fctionChange" event without any of the function codes does not assist towards helping us understand what is going on, let alone what you are trying to do...

Perhaps it would be best if you posted a link...


08-19-2004, 12:01 PM
neil9999 of the "WebDeveloper Forums" (http://www.webdeveloper.com/forum/showthread.php?s=&postid=231650#post231650)
found the solution.
I was wrong to think that it had something to do with the onLoad event.

Hereby you'll find the script so If other people are interested I hope they can use it.

<script type="text/javascript">
//Todays date
a=new Date();
//Date that hyperlink changes
b=new Date("December 25, 2004 12:00:00");
//converts times and dates into milliseconds
//goes to google if after date, yahoo if before

Again, thanks a lot for trying to help me.
I still have a long way to go.

And thank you very much: neil9999 of the "WebDeveloper Forums"

08-19-2004, 12:27 PM
<script type="text/javascript">

current = new Date();
expiration = new Date("August 24, 2004");

if (current > expiration){
window.location.href = "http://www.myDomain.com/newPage.html";


Doesn't take hours, minutes, seconds into account. So they will have a value of 00:00:00, or midnight. Just change the expiration date, and the link you want to forward to.

Edit: Sorry, guess you beat me to it...well, my script is a little shorter...whatever. Glad you got it sorted.


08-19-2004, 12:36 PM

Script is becoming more simple !! Where does it stop?
Maybe you're right about the seconds and the milliseconds and is midnight the best time to change.
I tried the previous script already and had some trouble with the time.
The moment the script should change pages, it did not work.
Maybe it is due to the fact that I live in the Netherlands and GMT (?).
I'll try your script today and will let you know if it's ok .... and also if it's not ok
Thank you very much.

Willy Duitt
08-19-2004, 01:03 PM
Cheers for updating this thread to reflect the solution you found... :thumbsup:


08-20-2004, 08:34 AM

As promised: it works !!!!


08-20-2004, 08:43 AM