Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.location.reload(); 

But the window is reloaded immediately after displaying the alertbox. Please Help me in it

like image 646
Nabeel Arshad Avatar asked Jun 06 '13 06:06

Nabeel Arshad


1 Answers

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!? :)

like image 148
Bojan Milic Avatar answered Oct 05 '22 20:10

Bojan Milic