2012-11-08 98 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位置

相關問題