/    Sign up×
Community /Pin to ProfileBookmark

From today’s links to other htmlpages after days.

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

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@BillyRayAug 19.2004 — 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
Copy linkTweet thisAlerts:
@neil9999Aug 19.2004 — Provided it isn't for anything essential that it goes to the right page (as Billy said):

[code=php]<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>[/code]


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

Neil
Copy linkTweet thisAlerts:
@jefgeesauthorAug 19.2004 — 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.
Copy linkTweet thisAlerts:
@neil9999Aug 20.2004 — Happy to help?
×

Success!

Help @jefgees spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...