javascript windows alert with redirect function

.guys I have the following code:

echo ("<SCRIPT LANGUAGE='JavaScript'>
        window.alert('Succesfully Updated')
        </SCRIPT>");

what i want to do is that when i click ok on the windows.alert the page will be redirected to a my edit.php.

or how is it possible to create a javascript which will execute an insert query.

Answers:

Answer

Alert will block the program flow so you can just write the following.

echo ("<script LANGUAGE='JavaScript'>
    window.alert('Succesfully Updated');
    window.location.href='http://someplace.com';
    </script>");
Answer

You could do this:

echo "<script>alert('Successfully Updated'); window.location = './edit.php';</script>";
Answer

If you would like to redirect the user after the alert, do this:

echo ("<script LANGUAGE='JavaScript'>
          window.alert('Succesfully Updated');
          window.location.href='<URL to redirect to>';
       </script>");
Answer

Use this if you also want to consider non-javascript users:

echo ("<SCRIPT LANGUAGE='JavaScript'>
           window.alert('Succesfully Updated')
           window.location.href='http://someplace.com';
       </SCRIPT>
       <NOSCRIPT>
           <a href='http://someplace.com'>Successfully Updated. Click here if you are not redirected.</a>
       </NOSCRIPT>");

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.