How to reload a page after the OK click on the Alert Page

后端 未结 10 1435
日久生厌
日久生厌 2021-01-01 18:25

I need to reload the page after the OK button is clicked on the Alert box. I am using the following code for it

alert(\"Successful Message\");
window.locati         


        
10条回答
  •  清酒与你
    2021-01-01 18:34

    Confirm gives you chance to click on cancel, and reload will not be done!

    Instead, you can use something like this:

    if(alert('Alert For your User!')){}
    else    window.location.reload(); 
    

    This will display alert to your user, and when he clicks OK, it will return false and reload will be done! :) Also, the shorter version:

    if(!alert('Alert For your User!')){window.location.reload();}
    

    I hope that this helped!? :)

提交回复
热议问题