homer.favenir Posted November 4, 2008 Share Posted November 4, 2008 hi, can anyone please tell me how to execute javascript first before redirect? i have a script here but it skips javascript and executes javascript. <script language="JavaScript"> alert ("Put your warning text here!") [removed] <?php redirect('Front_cont/input_dir_ufpb_wp'); ?> </script> i want to check if a file exist, if that file doesnt exist, it pops up an alert box and return to the input text page. the problem is it skips the alert message and just redirect the page. please advice. thanks Quote Link to comment https://forums.phpfreaks.com/topic/131295-javascript-before-redirect/ Share on other sites More sharing options...
corbin Posted November 4, 2008 Share Posted November 4, 2008 Chances are, the redirect() call is doing it's magic first. What exactly does redirect do? Send headers? Headers come before content, so of course it would be executed first. Quote Link to comment https://forums.phpfreaks.com/topic/131295-javascript-before-redirect/#findComment-681799 Share on other sites More sharing options...
homer.favenir Posted November 4, 2008 Author Share Posted November 4, 2008 i made it working now. i just made a new page when a file doesnt exist it will go to that page and in that page is the javascript <html> <head> <script type="text/javascript"> <!-- function delayer(){ window.location = "<?php echo 'input_dir_ufpb_wp'; ?>" } //--> </script> </head> <body onLoad="setTimeout('delayer()', 5000)"> <h2>Prepare to be redirected!</h2> <p>This page is a time delay redirect, please update your bookmarks to our new location!</p> </body> </html> thanks Quote Link to comment https://forums.phpfreaks.com/topic/131295-javascript-before-redirect/#findComment-681803 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.