window.location不能正常使用javascript

时间:2015-06-12 08:29:25

标签: javascript window.location

function showMessage()
{
  var num=new Array('25926419','9920084590','9867988449','28758869','28521181');
  var contact= document.getElementById('contact').value;
  if (num.indexOf(contact) > -1) 
  {
    window.location='address-directory.php';
  } 
  else
  {
    document.getElementById('errordiv').innerHTML="you are not allowed to see Member Details";
    $("#myModal").modal('show');
    return false;
  }  
}

window.location在此函数中无效,我想将其重定向到另一个页面

1 个答案:

答案 0 :(得分:0)

function showMessage()
{
  var num=new Array('25926419','9920084590','9867988449','28758869','28521181');
  var contact= document.getElementById('contact').value;
  if (num.indexOf(contact) > -1) 
  {
    window.location='address-directory.php';
  } 
else
 {
     document.getElementById('errordiv').innerHTML="you are not allowed to see Member Details";
 $("#myModal").modal('show');


}
 return false;

}

现在正在工作...... 我在之前的其他部分写过返回false ..............