jordz Posted March 25, 2010 Share Posted March 25, 2010 Hey All, I have a page on my website that takes the first item of the mysql table and sets the screen_id to 1. //get the first currently in queue $getfirst = "SELECT * FROM photos WHERE photo_id = '$screenphoto['photo_id']' ORDER BY photo_id DESC LIMIT 0,1"; $querygetfirst = mysql_query($getfirst); $screenphoto = mysql_fetch_array($querygetfirst, MYSQL_ASSOC); //change status $progressset = "UPDATE photos SET screen_id=1 WHERE photo_id =". $screenphoto['photo_id']; $inprogress = mysql_query($progressset); However, what I want is to happen is that when the X button is hit to close the browsing window the screen_id be turned back to 0? If the X button is clicked is there a way to run a part of the script before it closes? or even a java dialogue box that once okay is clicked is redirected to a new page?. Thanks Jordan Link to comment https://forums.phpfreaks.com/topic/196511-how-to-when-a-window-is-closed-run-a-script-or-bring-up-a-java-dialogue-box/ Share on other sites More sharing options...
ignace Posted March 25, 2010 Share Posted March 25, 2010 window.onbeforeunload = updateRecord_onWindowClose; // OR window.onunload = updateRecord_onWindowClose; Link to comment https://forums.phpfreaks.com/topic/196511-how-to-when-a-window-is-closed-run-a-script-or-bring-up-a-java-dialogue-box/#findComment-1031772 Share on other sites More sharing options...
Mchl Posted March 25, 2010 Share Posted March 25, 2010 1. JavaScript != Java 2. There is no reliable way of detecting that a browser has been closed, so do not rely on these examples. Link to comment https://forums.phpfreaks.com/topic/196511-how-to-when-a-window-is-closed-run-a-script-or-bring-up-a-java-dialogue-box/#findComment-1031774 Share on other sites More sharing options...
ignace Posted March 25, 2010 Share Posted March 25, 2010 2. There is no reliable way of detecting that a browser has been closed, so do not rely on these examples. Not to mention the annoyance it creates if it does do work. Link to comment https://forums.phpfreaks.com/topic/196511-how-to-when-a-window-is-closed-run-a-script-or-bring-up-a-java-dialogue-box/#findComment-1031796 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.