Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #13144 > unrolled thread

how to detect a page unload via closing a window

Started byzephyr <marc.at.compass@gmail.com>
First post2012-03-28 08:00 -0700
Last post2012-03-28 20:19 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.javascript


Contents

  how to detect a page unload via closing a window zephyr <marc.at.compass@gmail.com> - 2012-03-28 08:00 -0700
    Re: how to detect a page unload via closing a window David Mark <dmark.cinsoft@gmail.com> - 2012-03-28 20:19 -0700

#13144 — how to detect a page unload via closing a window

Fromzephyr <marc.at.compass@gmail.com>
Date2012-03-28 08:00 -0700
Subjecthow to detect a page unload via closing a window
Message-ID<4192865.8.1332946844959.JavaMail.geo-discussion-forums@vbuf25>
Hi,

I want an alert to appear when the user closes a browser window. That is easy enough - onBeforeUnload fires before unloading the window. But I want that alert only to show when the user leaves the page by closing the window: clicking the little x in the tab or top-right/left (Mac) of the window.
I don't want this alert to show when the user leaves the page by clicking a next button (since that is a legitimate pageunload). Also when he does a refresh, I don't want this alert to show up. OnBeforeUnload fires at all events when the current page is unloaded, be it from a close box click, a refresh or simply a redirect to another page.

Hope my question is clear...

Is there a way to do what I want?

Marc

[toc] | [next] | [standalone]


#13153

FromDavid Mark <dmark.cinsoft@gmail.com>
Date2012-03-28 20:19 -0700
Message-ID<7f3c1613-5be7-4ec6-9349-b70eaf2f5b02@q11g2000vbu.googlegroups.com>
In reply to#13144
On Mar 28, 11:00 am, zephyr <marc.at.comp...@gmail.com> wrote:
> Hi,
>
> I want an alert to appear when the user closes a browser window. That is easy enough - onBeforeUnload fires before unloading the window. But I want that alert only to show when the user leaves the page by closing the window: clicking the little x in the tab or top-right/left (Mac) of the window.
> I don't want this alert to show when the user leaves the page by clicking a next button (since that is a legitimate pageunload). Also when he does a refresh, I don't want this alert to show up. OnBeforeUnload fires at all events when the current page is unloaded, be it from a close box click, a refresh or simply a redirect to another page.
>
> Hope my question is clear...
>
> Is there a way to do what I want?
>

No.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web