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!
<!-- 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;
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.
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.
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?