How to make javascript code to run after page redirection?

I use this code to redirect my current page. I want to give an alert to the user after redirection. I use these codes:

header("Location: ../../admin/manage");
echo '<script type="text/javascript">fail();'
function success() {
alert("File deleted successfully!");
function fail() {
alert("File not found");

The alert is not shown.


If you are redirected to a different page… YOU ARE NO LONGER ON THAT PAGE.

What makes you think the following JS code would execute… if you are no longer on that page?

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service