• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Warn user when the user tries to close the window

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need to warn the user with some message when the user tries to close the browser window by clicking on the 'X' close icon on the browser window's title bar.

Is there a javascript which works for all browsers to do that? I don't want to use onUnload() as this gets called only after the window is unloaded. The beforeUnload() function works only for IE browsers.

Please suggest me a suitable solution.

Thanks in advance,
Sreeni.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no solution...
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a Solution. In our company's Intranet application , if we close the window by clicking the X mark instead of not logging out properly, a new popup window opens saying you haven't logged out properly and then automatically closes.

So far i havent tried to lookout the code for it, i'l lookout after sometime and post it here..
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
onunload is what fires when the user leaves, but it does it for every action including refresh, back, close, links, etc.

PLUS onunload popup windows are blocked by popup blockers

Eric
reply
    Bookmark Topic Watch Topic
  • New Topic