Forum Moderators: open
I'm in the process of building a 'on this day in history' site, and am looking for a javascript which will automatically load up the correct page for the current date (day & month). Needless to say the site will either have...
(a) 366 pages (a page for every day of the year, inc. Feb 29th) or;
(b) 12 pages (1 for each month) with a 'month.html#date' tag so that the month page loads up and automatically selects the correct day on the page. (i.e. 12.html#02 for December 2nd, 03.html#23 for March 23rd, etc)
If anyone can help me with this, I will be very greatful.
Cheers. ;)
I think I may've got round this though...
I've designed the index page so that it contains the follow coding:
<HTML>
<HEAD>
<SCRIPT type="text/javascript">
<!-- Begin
function monthPage() {
today = new Date();
m = new Array("January.html","February.html","March.html","April.html","May.html",
"June.html","July.html","August.html","September.html","October.html",
"November.html","December.html");
window.location = m[today.getMonth()];
}
// End -->
</script>
</HEAD>
<BODY OnLoad="monthPage()"></BODY>
</HTML> This selects the current month page (e.g. December.html), and then each month page contains...
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var today = new Date();
var day = today.getDate();
window.location = "#" + day;
// End -->
</SCRIPT> ...between the <HEAD></HEAD> tags.
This then selects the date of the month (e.g. 2nd) and automatically loads it from the month page (i.e December.html#2). Needless to say I have opted for option (b) in my above post. It's, no doubt, a long winded way of doing it but seems to work fine.
The pages contain just text (i.e no graphics) of events which happened 'on this day' in history.
[edited by: JavaLava at 2:44 pm (utc) on Dec. 2, 2007]
[edited by: encyclo at 7:01 pm (utc) on Dec. 2, 2007]
[edit reason] fixed formatting [/edit]