单击“警报”页面后,如何重新加载页面 [英] How to reload a page after the OK click on the Alert Page

查看:72
本文介绍了单击“警报”页面后,如何重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在警报框中单击确定按钮后重新加载页面。
我使用以下代码

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

推荐答案

确认让您有机会点击取消,重新加载将无法完成!

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(); 

这将向您的用户显示提醒,当他点击OK时,它将返回false并重新加载完成! :)
此外,更短的版本:

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

这篇关于单击“警报”页面后,如何重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆