Click to See Complete Forum and Search --> : From today's links to other htmlpages after days.


jefgees
08-19-2004, 04:07 AM
Hello,
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 already, but maybe I was not clear enough.
So this is a new try to set things straight.
Sorry .. and thanks for trying to help me.

jef

BillyRay
08-19-2004, 04:18 AM
Showing a user a page based upon a client-side date is always risky, as all the user has to do is change their date, and they could see any page they liked.

I suggest investigating a server-side solution.

Hope this helps,
Dan

neil9999
08-19-2004, 04:25 AM
Provided it isn't for anything essential that it goes to the right page (as Billy said):

<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
a2=a.getTime();
b2=b.getTime();
//goes to google if after date, yahoo if before
window.location=(a2>b2)?"http://www.google.co.uk":"http://www.yahoo.co.uk";
</script>

Make sure you remove the unneccesary new lines put in by the forum,

Neil

jefgees
08-19-2004, 04:48 AM
neil9999

thanks.
Did not know it was that simple (?),
I was making it too difficult.
But only the master can make it look simple.
Student still got a very long way to go.
I was thinking of making a script that compared the dates (today and future) on the <body onLoad" "> event. But as I mentioned earlier, it is simple as you know how.

Thanks a lot neil9999.

neil9999
08-20-2004, 03:54 AM
Happy to help:D