2012-11-08 103 views
-1

在我的代码我无法重定向到新页面时登录是正确的,而不是“window.location.href”,window.location.replace是working.how使此代码工作window.location.href不工作在我的代码,但window.location.replace工作

$(document).ready(function(){ 
    $('#login').click(function(){ 

     $('.errordisp').empty(); 

     var spgremail=$('#mailid').val(); 
     var spgrpwd=$('#pwd').val(); 
     if(spgremail=='' || spgrpwd==''){ 

      var txt=$('#errormsg8').text(); 
      $('.errordisp').append(txt);//removeClass('hidden').addClass('errordisp'); 

     } 
     else 
     { 
      $.post("in.php",{email: spgremail,pass: spgrpwd},function(data) { 

       if(data) 
       { 

        window.location.href("http://abcd.com/discover.php"); 

       } 
       else 
       { 
        txt=$('#errormsg3').text(); 
        $('.errordisp').append(txt); 
       } 

      }); 

     } 

    }); 
}); 

回答

3

window.location.href属性不是一个功能,您必须将URL分配给它像

window.location.href = "http://abcd.com/discover.php"; 
1

更改代码

window.location.href("http://abcd.com/discover.php"); 

window.location.href="http://abcd.com/discover.php"; 

window.location.href不是方法,这是一个属性,它会告诉你浏览器的当前URL位置

相关问题