首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

超级链接应用javascript有关问题

2012-03-05 
超级链接应用javascript问题我想点一个超级链接后先利用javascript判断当前月份是否满足要求,满足的话跳转

超级链接应用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月

这句改改

热点排行
Bad Request.