1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Javascript & browser closing

Discussion in 'HTML & JavaScript' started by wargamer6, Dec 9, 2009.

  1. wargamer6

    wargamer6 Junior Member

    Joined:
    Apr 13, 2008
    Messages:
    190
    Likes Received:
    47
    Does anyone have working code that would display a prompt when a user tried closing their browser window? I've found a couple different ones but they do not work for me.
     
  2. Kaimi

    Kaimi Newbie

    Joined:
    Dec 6, 2009
    Messages:
    35
    Likes Received:
    230
    Home Page:
    Works in my browsers (IE6, Firefox)
    Code:
    <html>
    text
    <script>
    window.onbeforeunload = function(evt) {
        evt = evt || window.event;
        evt.returnValue = "Exit?";
    }
    </script>
    </html>