dseg42 — 2011-03-24T15:04:34-04:00 — #1
I have a website with all of the months of the year. The main page of the website is suppose to be the current month. How can make my index page load automatically to the correct month. So if it is April, my index page will automatically load april.html.
Thank you so much!
jason__c — 2011-03-24T15:44:16-04:00 — #2
<!-- Hide from older browser
var x= new Date();
var m= x.getMonth()+1 ;
document.location.href =" + m + .html";
You can also use a switch:
var dateobj=new Date()
var month=dateobj.Month() + 1;
felgall — 2011-03-24T16:47:50-04:00 — #3
felgall — 2011-03-24T16:53:11-04:00 — #4
You should be more specific about which browsers you are hiding the script from when you include that code.
The older browsers it refers to are Internet Explorer 2, Netscape 1, and the browsers that preceded them.
The comment doesn't hide the script from Internet Explorer 3 or Netscape 2 or more recent browsers than those.
At the current rate of browser development it should be possible to do away with such comments once everyone stops using Netscape 1 and IE2 - which will most likely happen long before the end of the 20th century - say 1998 to play it safe.
jason__c — 2011-03-24T17:01:16-04:00 — #5
Alright man, I'm not the best at JS, but regardless off the comments I added, to hide from older browsers, the rest will still work. Just giving the guy a jump-start, which he can build from. Not a copy-and-paste. However, I didn't take into account using a server-side solution, as this post is in the JS Forum.
dseg42 — 2011-03-24T18:18:38-04:00 — #6
wow thank you so much! I used the first example and i have another question. I know this is the JS forum but how do I make a html file open another html file in the same directory?