Skip to content Skip to sidebar Skip to footer

Infinite Loop Of Alert Messages

I want to display alert message and then refresh the page. But it take infinite loop of alert messages. if(isValid){ alert('alert some text'); document.location.relo

Solution 1:

You would have to pass along the state. Possibly refreshing the page by pointing itself with a querystring variable. Then read that variable

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

Note the getParameterByName function is found at another stackoverflow answer: How can I get query string values in JavaScript?. You could alternatively use a library such as jQuery for a better solution.

Post a Comment for "Infinite Loop Of Alert Messages"