SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast bokz_42's Avatar
    Join Date
    Sep 2006
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    close browser manupulation

    hi, just wanna ask how to manipulate the browser...

    say the user clicks on the 'X' button, this will close the window. but what i want to do is to ask the user if he/she really wants to close the window. if yes, then the window will close, if not, then the current window will stay the same and not close. thanks in advance!

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Some browsers have a non-standard onbeforeunload event that you could use to ask that.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Enthusiast bokz_42's Avatar
    Join Date
    Sep 2006
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im now using the onbeforeunload event, but this event is messing with my ajax script. now everytime i click to load another page inside my parent page, it asks me to where i will close the window or not.

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    That's the problem with trying to do such things - there is no way to distinguish between different reasons for why the current page is unloaded - refreshing the page, going to a different page, and closing the browser all trigger that same event.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bokz_42 View Post
    say the user clicks on the 'X' button, this will close the window. but what i want to do is to ask the user if he/she really wants to close the window.
    Why would the user click the 'X' button unless he/she wants to close the window?
    Birnam wood is come to Dunsinane


Bookmarks

Posting Permissions

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