Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
441 views
in Technique[技术] by (71.8m points)

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

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

(请帮帮我)

  ask by Nabeel Arshad translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!

(这将向您的用户显示警报,当他单击“确定”时,它将返回false并完成重新加载!)

:) Also, the shorter version:

(:)另外,较短的版本:)

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

I hope that this helped!?

(希望对您有所帮助!?)

:)

(:))


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...