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 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> 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 Hi, I want an alert to appear when the user closes a browser window. That is ea= sy enough - onBeforeUnload fires before unloading the window. But I want th= at 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 r= efresh, I don't want this alert to show up. OnBeforeUnload fires at all eve= nts when the current page is unloaded, be it from a close box click, a refr= esh or simply a redirect to another page. Hope my question is clear... Is there a way to do what I want? Marc