Re: CakePHP + JS/AJAX - performing actions on browser window close - is it possible?

2010-03-10 Thread cricket
This isn't really a Cake question. You'd probably get a better
response from a javascript list.

I did something like that once. IIRC, you need to register a function
to fire for body.onUnload because window.onClose is unreliable unless
you used JS to open the window in the first place. Something like
that.

In your case, the simplest thing might be to set a cookie whenever an
order is created (obviously, update that if the item is removed) and
check that in your onUnload handler.

On Mar 10, 6:31 am, Anna P  wrote:
> Hello!
>
> I have a question, is there a way to perform an action, when user
> tries to close browser window?
>
> For example: in an on-line store, when unregistered user places some
> order and doesn't proceed to payment system (its order is still not
> paid) and wants to leave website/close browser window.
> Is there a way in that case to display an information box on browser
> window close attempt like "You have an order which hasn't been paid
> yet. Would you like to pay for order?" and if user clicks "Yes" it
> redirects him to some URL address with order details and doesn't close
> browser window. And if he clicks "No", before window is closed, some
> actions are performed on Database (order and all its relative
> information is deleted).
>
> Many thanks in advance!
> Anna

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


CakePHP + JS/AJAX - performing actions on browser window close - is it possible?

2010-03-10 Thread Anna P
Hello!

I have a question, is there a way to perform an action, when user
tries to close browser window?

For example: in an on-line store, when unregistered user places some
order and doesn't proceed to payment system (its order is still not
paid) and wants to leave website/close browser window.
Is there a way in that case to display an information box on browser
window close attempt like "You have an order which hasn't been paid
yet. Would you like to pay for order?" and if user clicks "Yes" it
redirects him to some URL address with order details and doesn't close
browser window. And if he clicks "No", before window is closed, some
actions are performed on Database (order and all its relative
information is deleted).

Many thanks in advance!
Anna

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en