Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Oct 2002
    Location
    Lakewood, New Jersey, USA
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    prevent user from closing web page

    How can I prevent a user from closing a web page in my web application by clicking the little x button in the upper right corner. In particular, I have a modal dialog window that I use to get user input. If the user closes the dialog window by clicking the x button, I can't force her to give me the input that I need.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: prevent user from closing web page

    There is a window.unload event in JavaScript, but I'm not sure that it allows you to cancel the close... you might have to check for the information you want and redisplay the window... I've never tried it. But judging from the annoying ad sites that pop open a new window every time you close one, it can be done. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  3. #3
    2 Star Lounger
    Join Date
    Oct 2002
    Location
    Lakewood, New Jersey, USA
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: prevent user from closing web page

    Thanks! I guess I can create a while loop that loops as long as the returnValue of the modal dialog window is empty. That will be pretty annoying for the user - I'll have to think about it.

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: prevent user from closing web page

    Web browsers were not originally designed to function as an application host, such as Visual Basic, Visual FoxPro, or even Access. The early web browsers were used for displaying formatted (static) data only. Dynamic data and web applications came as an afterthought.

    Controlling when/if the window is closed, preventing the user from navigating away from the application, and other basic features that Windows application developers take for granted are issues of much concern for web developers.

    Just my 2 cents <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15>

Posting Permissions

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