Re: Re: close the browser

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 24 June 2014 19:53, Tim Streater <tim@xxxxxxxxxxxxxxxx> wrote:

> On 24 Jun 2014 at 17:43, Stuart Dallas <stuart@xxxxxxxx> wrote:
>
> > I'm yet to hear of a legitimate reason to want some PHP to execute when
> > a user closes the browser, so chances are there's a better way to achieve
> > what he actually wants.
>
> I use that in my app. If the user has been typing into an editing window,
> and then closes the browser window, they will expect that what they typed
> will show up again when they restart the app. I use the onbeforeunload
> event in the browser to handle this, along with a (rare) synchronous ajax
> request to run a PHP termination script.
>

That's certainly a solution to that problem. In the past I've used
onbeforeunload to check if the user has edited anything and display a
confirmation dialog, but never to make a request to the server. I'm
struggling to identify why, but doing that just doesn't sit right with me.
It may be because I've heard that the event is not reliably thrown by all
browsers in all situations as a result of various spammy behaviour by dodgy
sites in the past. That view may well be out of date now. Have you seen any
problems like that?

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux