I want a JS popup to appear after something is successfully completed. How do I make it appear, and disappear only when the user closes it, then redirect to the next page? By the way this is in a php file. I used print to print the code for a JS alert to the page, then redirect, but that makes the popup only appear if your computer is very slow - it makes the popup but then quickly redirects. How do I fix this?
1 Answer
If you want to use the redirect()
function provided in pset7 I'm not sure how, but in general you can do it like so:
echo "<script type='text/javascript'>
if (confirm('Want to redirect?'))
{
location.href = 'http://www.google.com/';
}
</script>";
-
-
-
-
print("<script>\nnif(alert('Text!'))\n{\nlocation.href=link\n}\n</script>");
Commented Jul 28, 2015 at 22:13 -
Why what happens? I tested it and it works for me. Make sure to remove any
redirect
calls you have after that.– ChrisGCommented Jul 28, 2015 at 22:14