how to catch a user 'X' ing the tab? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: how to catch a user 'X' ing the tab? (/showthread.php?tid=79003) |
how to catch a user 'X' ing the tab? - richb201 - 04-07-2021 My application uses only a single tab. When the user presses the regular "logoff" button my code runs the send_to_locker() function. But I also need to catch when users just X out the tab in the browser. How to do this? I tried putting the below line into my code but that doesn't seem to work. <body onbeforeunload="return send_to_locker()"> public function send_to_locker() { //some junk } Basically I am trying to store a user's "state" for the next time they visit. My code tries to send a few needed files to S3. If my server could somehow tell that the client is no longer connected, that might do it. How can I do this? RE: how to catch a user 'X' ing the tab? - InsiteFX - 04-07-2021 How to know a Browser Tab Close or Refresh with JavaScript Trying to detect browser close event RE: how to catch a user 'X' ing the tab? - richb201 - 04-07-2021 Thanks Insite. Is there any ability under CI to start up an asynch thread ? I have a need to download a bunch of images and don't want to lock up the UI while I am doing this? RE: how to catch a user 'X' ing the tab? - InsiteFX - 04-07-2021 You would need to use JavaScript Ajax for that it has a switch for it. RE: how to catch a user 'X' ing the tab? - richb201 - 04-13-2021 AWS has an asynch transfer (to s3) that I will use. Thkx |