From: Pif on
Hello, I've successed to capture de window closing event in my page.
This unload event is also generated when going to another page of the
website. I would like to be able to compare current URL with new one.
How can I get the information of the new URL (none if closing ?) ?

Thanks.
From: Jeremy J Starcher on
On Tue, 06 Apr 2010 14:11:33 -0700, Pif wrote:

> Hello, I've successed to capture de window closing event in my page.
> This unload event is also generated when going to another page of the
> website. I would like to be able to compare current URL with new one.
> How can I get the information of the new URL (none if closing ?) ?
>
> Thanks.

No can do.

Why are you trying to detect if someone is leaving your web site?
From: Pif on
We have an internal ERP. I need to modify session management to detect
that a user disconnects and to free his resources. So, I would like to
create following behaviour :
- modal window on close to nothing
- std window on close open dialog to suggest disconnection

On 6 avr, 23:30, Jeremy J Starcher <r3...(a)yahoo.com> wrote:
>
> Why are you trying to detect if someone is leaving your web site?

From: Sean Kinsey on
On Apr 7, 9:25 am, Pif <fjs...(a)laposte.net> wrote:
> We have an internal ERP. I need to modify session management to detect
> that a user disconnects and to free his resources. So, I would like to
> create following behaviour :
> - modal window on close to nothing
> - std window on close open dialog to suggest disconnection

This is an approach that I use:
On onunload, open up a small window with window.open which contains a
script that waits a short duration and then attemts to access
window.opener.document.
If this succeeds then the document contained in the window is in the
same domain, and you can check the url. If it fails (try/catch) then
it has been navigated outside the domain.
Do the appropriate action and close the window.
From: rf on
Sean Kinsey wrote:
> On Apr 7, 9:25 am, Pif <fjs...(a)laposte.net> wrote:
>> We have an internal ERP. I need to modify session management to
>> detect that a user disconnects and to free his resources. So, I
>> would like to create following behaviour :
>> - modal window on close to nothing
>> - std window on close open dialog to suggest disconnection
>
> This is an approach that I use:
> On onunload, open up a small window with window.open which contains a
> script that waits a short duration and then attemts to access
> window.opener.document.
> If this succeeds then the document contained in the window is in the
> same domain, and you can check the url. If it fails (try/catch) then
> it has been navigated outside the domain.
> Do the appropriate action and close the window.

And if the user simply closes their browser? Or pulls the computers plug out
of the wall?

Detecting what the OP wants is simply not possible. Any design that relies
on this is flawed and should be re-designed, as has been mentioned in many
newsgroups many many times.