Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2003
    Thanked 0 Times in 0 Posts

    Question Can I stop the browser from being closed?

    Our project stakeholders have asked that we add in a "Are you sure you want to quit?" prompt when/if the user clicks on the close ("X") icon in the upper-right corner. They'll also want this on an Alt-F4 or system menu "Close".

    I tried to invoke a javascript from the <body onunload=""> with a call to window.confirm, and it did get called, but too late. The browser was long gone by the time I had clicked on the button in the confirmation window.

    I suspect that this is impossible, but I'm hoping that somebody might have figured out a way to do this. Any suggestions, tips, scripts, etc (or even a defniitive "no") will be appreciated.

  2. #2
    Master Coder
    Join Date
    Feb 2003
    Umeň, Sweden
    Thanked 83 Times in 74 Posts
    Try using onbeforeunload, that should work in the browsers that support it.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts