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


Groups > comp.lang.javascript > #13144

how to detect a page unload via closing a window

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From zephyr <marc.at.compass@gmail.com>
Newsgroups comp.lang.javascript
Subject how to detect a page unload via closing a window
Date Wed, 28 Mar 2012 08:00:44 -0700 (PDT)
Organization http://groups.google.com
Lines 17
Message-ID <4192865.8.1332946844959.JavaMail.geo-discussion-forums@vbuf25> (permalink)
NNTP-Posting-Host 145.18.144.37
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-Trace posting.google.com 1332949365 429 127.0.0.1 (28 Mar 2012 15:42:45 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Wed, 28 Mar 2012 15:42:45 +0000 (UTC)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=145.18.144.37; posting-account=tRhYkQoAAAC4mfP99Qw2QppE0qHeI37Z
User-Agent G2/1.0
X-Received-Bytes 1705
Xref csiph.com comp.lang.javascript:13144

Show key headers only | View raw


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

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

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

csiph-web