Re: Re: pulling script in interval of second.
| From: | Stuart Dallas | Date: | Tue, 01 Jul 2014 20:38:55 +0000 |
| Subject: | Re: Re: pulling script in interval of second. | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-323578@lists.php.net to get a copy of this message | ||
On 1 July 2014 21:36, Aziz Saleh <azizsaleh@gmail.com> wrote:
> On Tue, Jul 1, 2014 at 4:31 PM, hadi <almarzuki2011@hotmail.com> wrote:
>
> > I already tried onbeforeunload and unload event. But the problem when
> user
> > change the page or navigate to different page code will be executed. And
> I
> > don’t this to happen.
> > Thank you for your help.
> >
> > I just want a method to keep pulling my php script once its stopped block
> > in if statement should run in my php script.
> >
> > > On 01 Jul 2014 at 20:04, hadi <almarzuki2011@hotmail.com> wrote:
> > >
> > > > I got another idea just listen to me. I got javascript passing "id"
> to
> > > > my php script in interval time, once the "id" not being passed (its
> > > > mean the user close javascript page). Block in if statement should
> > > > run. But this scenario is not happening with me.
> > >
> > > If the user closes the page then no PHP script will be run unless you
> do
> > it with
> > > onbeforeunload event.
> > >
> > > --
> > > Cheers -- Tim
>
> Do the onunload, and add a check in you PHP (store the info in the DB)
> that if the user doesn't refresh within 2 seconds (enough time to navigate
> to a different page on the domain), then mark as out.
>
That's nasty. There should be Javascript attached to any event that might
change the page, that checks where that event is taking the user and is
enabling/disabling the onbeforeunload accordingly. PHP should not be
involved in that logic in any way.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/