PDA

View Full Version : switch redirect problems


charbort
02-18-2003, 08:53 PM
I have the following code to try and redirect a visitor to the
page specified for that month. I would like it to redirect
before this page loads so they don't even see this page.
Any ideas?

Thanks,
Charbort



<script language="JavaScript1.2">
var dateobj=new Date()
var month=dateobj.getMonth()

switch(month){
case1:
window.location="calendar_jan.html"
break
case2:
window.location="calendar_feb.html"
break
case3:
window.location="calendar_mar.html"
break
case4:
window.location="calendar_apr.html"
break
case5:
window.location="calendar_may.html"
break
case6:
window.location="calendar_jun.html"
break
case7:
window.location="calendar_jul.html"
break
case8:
window.location="calendar_aug.html"
break
case9:
window.location="calendar_sep.html"
break
case10:
window.location="calendar_oct.html"
break
case11:
window.location="calendar_nov.html"
break
case12:
window.location="calendar_dec.html"
break
}
</script>




<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="switch(month); MM_preloadImages('../images/nav/mo_home.gif','../images/nav/mo_eservices.gif','../images/nav/mo_h&amp;f.gif','../images/nav/mo_recreation.gif','../images/nav/mo_w&amp;c.gif','../images/nav/mo_e&amp;o.gif','../images/nav/mo_inside.gif')">

beetle
02-18-2003, 09:26 PM
Don't need a switch for that...

var months = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];
var d = new Date();
window.location.replace( "calendar_ " + months[d.getMonth()] + ".html" );

charbort
02-19-2003, 12:05 AM
works great, thanks