Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q472 How can I redirect a page depending the date, for example: automatically, monday I redirect to monday.htm and sunday I redirect to sunday.htm?

irt.org | Knowledge Base | JavaScript | Redirect | Q472 [ previous next ]

Q472 How can I redirect a page depending the date, for example: automatically, monday I redirect to monday.htm and sunday I redirect to sunday.htm?

Try:

<script language="JavaScript"><!--
function makeArray() { for (i = 0; i<makeArray.arguments.length; i++) this[i] = makeArray.arguments[i]; }

var daysArray = new makeArray('sunday','monday','tuesday','wednesday','thursday','friday','saturday');

var today = new Date();    // get todays date
var dotw = today.getDay(); // get the day of the week
                           // Sunday = 0, Monday = 1 ... Saturday = 6

location.href = daysArray[dotw] + '.htm';
//--></script>

Also see the answer to Q985


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.