Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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?

You are here: irt.org | FAQ | JavaScript | Redirect | Q472 [ previous next ]

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

©2018 Martin Webb