How do I tell the browser to reload the page after closing the alert box? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I tell the browser to reload the page after closing the alert box?

Hey there, I have been struggling to find a command that would refresh the page after you click "Ok" on an alert box, so my question is "is there any way to tell the browser to reload the page after you close the alert box?" To be more specific I don't have this problem when i open my script on a web browser as an .html file but it appears only when i run the code through the SoloLearn Code Playground using a PC (It works fine with the mobile app) This is what appears after you close the alert box: http://prntscr.com/ly00dk

21st Dec 2018, 3:41 PM
Miki Sarkovski
Miki Sarkovski - avatar
3 Answers
+ 3
use confirm instead of alert <script type="text/javascript"> var answer = confirm ("reload ?") if (answer) location.reload(); </script> edit: if you're looking for alert only; use the location.reload(); after the alert();
21st Dec 2018, 3:51 PM
Ahlin Chan
Ahlin Chan - avatar
+ 2
use window.location.reload(true) after alert
21st Dec 2018, 3:47 PM
Taste
Taste - avatar
0
The same thing happens... (http://prntscr.com/lxzxa0) Is it possible for this to be a bug into the Code Playground app? Or is my code wrong?
21st Dec 2018, 4:47 PM
Miki Sarkovski
Miki Sarkovski - avatar