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
Try this code..
IN PHP Code
IN Javascript
Use javascript
confirm()
method instead of alert. It returnstrue
if the user clicked ok button and returnsfalse
when user clicked on cancel button. Sample code will look like this :You can write above code in this format also.It seems quite decent
As the alert method in JavaScript does not return a Boolean or yield the current thread, you must use a different method.
My number one recommendation requires a little CSS experience. You should instead create a div element that is fixed positionally.
Otherwise you could use the confirm() method.
However, this will add a cancel button. Because the confirm method is not within an if statement though, the cancel button will still refresh the page like you want it.
Interesting that Firefox will stop further processing of JavaScript after the relocate function. Chrome and IE will continue to display any other alerts and then reload the page. Try it:
Bojan Milic answer work in a way but it error out with a message below,
This can be avoid with,