日期:2014-05-16  浏览次数:20383 次

超级链接应用javascript问题
我想点一个超级链接后先利用javascript判断当前月份是否满足要求,满足的话跳转到A页面(如以下代码中的www.163.com),否则给以警告,并跳转到B页面(如以下代码中的baidu)。对超级链接的代码该如何写呢?我这么写的:<a href="javascript:Myinfor();" >A页面</a>,但怎么都不行。望大侠指点,不胜感激。


  <script language="JavaScript">
function Myinfor(){ //Myinfor函数
var currentMonth ;
currentMonth=new date.getMonth();//将月份赋值给变量
if (currentMonth>8 and currentMonth<11) { //判断月份是否是9月或10月
window.location.href("http://www.163.com");

}
else{
alert("请在规定的时间内注册!");
  window.location.href("http://www.baidu.com");
}
}
</script>

------解决方案--------------------
<script type='text/javascript'>

function Myinfor(){ //Myinfor函数 
var currentMonth ; 
currentMonth=new Date().getMonth();//将月份赋值给变量 
if (currentMonth>8 && currentMonth <11) { //判断月份是否是9月或10月 
window.location.href="http://www.163.com";


else{ 
alert("请在规定的时间内注册!"); 
window.location.href="http://www.baidu.com";



window.onload=Myinfor;
</script>
------解决方案--------------------
怎么还不行??

报错? 不能链接过去?

if (currentMonth==8 || currentMonth ==9) { //判断月份是否是9月或10月

这句改改