1

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 1

1

If you want to use the redirect() function provided in 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>";
13
  • Thanks! I'll test it out now
    – i_am_david
    Commented Jul 28, 2015 at 22:06
  • Ok. Let me know how it went.
    – ChrisG
    Commented Jul 28, 2015 at 22:06
  • It didn't work.. :(
    – i_am_david
    Commented Jul 28, 2015 at 22:13
  • print("<script>\nnif(alert('Text!'))\n{\nlocation.href=link\n}\n</script>");
    – i_am_david
    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.
    – ChrisG
    Commented Jul 28, 2015 at 22:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .