PDA

View Full Version : getMonth()...


shaneLost
03-17-2005, 12:32 AM
Hello all:
I have a question about JS. I have some JS that will check to see what month it is and display a message to the user. What I would really like for this JS to do is display a new homepage depending on what month it is. Does any one know of a way I can do this?

<script language="JavaScript" type="text/javascript">
<!--
var day = new Date()

<!-- shows new homepage for the holidays -->

function Page()
{
var day = new Date()

if (day.getMonth() ==2)
alert("hello");
else
alert("no");
}
//-->
</script>

Thanks again for any help!!

IKLOP
03-17-2005, 01:07 AM
you can use window.location.href to change the url, for example:

<script language="JavaScript" type="text/javascript">
<!--
var day = new Date()

<!-- shows new homepage for the holidays -->

function Page()
{
var day = new Date()

if (day.getMonth()==2)
window.location.href="http://www.yourpage.com/march.html";
else
window.location.href="http://www.yourpage.com/notmarch.html";
}
//-->
</script>

shaneLost
03-17-2005, 10:28 AM
:rocker: Thanks alot :D You the man.

senshi
03-25-2005, 05:29 AM
If your page is used as a redirector then static pages can be called by a predeterminted name, allowing you to edit part of the name to suit.



<script>
<!--
window.location.href="http://www.domain.com/homepage_"+["jan","feb","mar","apr","may5","jun","jul","aug","sept","oct","nov","dec"][new Date().getMonth()]+".html";

//-->
<script>