警报消息的无限循环



我想显示警报消息,然后刷新页面。

但它需要无限循环的警报信息。

   if(isValid){
      alert("alert some text");
      document.location.reload(true);
   }
   else {
       .............
   }

我如何使用无限循环来做到这一点

您必须传递状态。可能通过用querystring变量指向页面本身来刷新页面。然后读取变量

if (getParameterByName("reloaded") != "yes") {
    alert("username or password are incorrect");       
    window.location = 'mypage.html?reloaded=yes';  
} else {
    // Do something else..
} 

注意,getParameterByName函数在另一个stackerflow答案中找到:如何在JavaScript中获取查询字符串值?。您也可以使用像jQuery这样的库来获得更好的解决方案。

最新更新