JRS: In article <3e************@news.dfncis.de>, dated Sun, 8 May 2005
12:54:37, seen in news:comp.lang.javascript, =?ISO-
8859-15?Q?Lutz_I=DFler?= <tr***@lutzissler.net> posted :
If you really want to use the client date, try
var dat = new Date();
location.href = "path/to/you/html/"+dat.getDay()+".html";
That would call pages like "7.html" on the 7th of May.
It would never call for 7.html. Please test code before posting.
Another solution
would be
var dat = new Date();
location.href = "path/to/you/html/page.html?day="+dat.getDay();
which calls "page.html?day=7".
It will never do that.
If you want to encode the client date to make the fact that the page is
date-driven somewhat less obvious, do some calculations on the date, eg.
var dat = new Date();
var day = dat.getDay()*35+17;
location.href = "path/to/you/html/"+dat.getDay()+".html";
You're not using var day.
On the server-side, you will have to revert this calculation by taking
the encoded day number, subtracting 17, and dividing by 35.
Not necessarily, if the possible values of day are correctly predicted
and the pages named accordingly.
D.getDate() -> 1..31
D.getDay() -> 0..6
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.