veedub Posted March 8, 2007 Share Posted March 8, 2007 Hello!! I'm running a PHP script on page1.php that takes a few seconds, once it has run the page then redirects to page2.php automatically sending variables . However, if the user shuts page1.php by pressing the X on the top right of the screen, the redirect doesn't happen!! Does anyone know how to disable the X and stop the page being closed down please?? or another solution?? Cheers! James Quote Link to comment Share on other sites More sharing options...
magnetica Posted March 8, 2007 Share Posted March 8, 2007 Well if someone shuts the window then they obviously don't want to view it.. And I don't think there is a way Quote Link to comment Share on other sites More sharing options...
paul2463 Posted March 8, 2007 Share Posted March 8, 2007 put up an echo statement on the page that takes a few seconds to load explaining what is happening and that they will be redirected shortly, an informed customer is usually quite happy to see what happens. Quote Link to comment Share on other sites More sharing options...
veedub Posted March 8, 2007 Author Share Posted March 8, 2007 ok cheers, is there a way to make the window really small before the php script runs in the page? when I use the resize function: <script> window.resizeTo(width, height); </script> it runs after the PHP script, which is no use. Quote Link to comment Share on other sites More sharing options...
obsidian Posted March 8, 2007 Share Posted March 8, 2007 There isn't a way to disable a feature of a desktop application via a web script. You can run a javascript window.close check and try to confirm that they really want to exit, but I believe this will only work in IE anyway. Quote Link to comment Share on other sites More sharing options...
obsidian Posted March 8, 2007 Share Posted March 8, 2007 ok cheers, is there a way to make the window really small before the php script runs in the page? when I use the resize function: <script> window.resizeTo(width, height); </script> it runs after the PHP script, which is no use. Javascript is a client run language, so it doesn't even load until the server script has completely finished parsing and has begun outputting data to the browser. What you would have to do is have your first page be only your javascript resize and then forward it on to the script pages where your PHP would run. Quote Link to comment Share on other sites More sharing options...
paul2463 Posted March 8, 2007 Share Posted March 8, 2007 to give you an answer to your point before Obsidian made his post PHP is parsed and run on the server before your client machine ever sees any information, therefore having a javascript function on your clients machine will ALWAYS run after the php script has finished - hope that helps EDIT: thanks OBS, both at the same time, you got there first Quote Link to comment Share on other sites More sharing options...
legohead6 Posted March 8, 2007 Share Posted March 8, 2007 lol..what do you expect the users to do if your site freezes or something local stops your page, if there is no x button... Quote Link to comment Share on other sites More sharing options...
artacus Posted March 8, 2007 Share Posted March 8, 2007 You CAN use Javascript during a long running php script. Set ob_implicit_flush() at the top of your page. You can then output any javascript and html and then go to processing your script. Typically I'll use a progress meter in these situations. Some other things you might try are using a pop-under to open a new window but forcing the opener to stay on top and have focus. Quote Link to comment 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.