SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    'X' button at browser... can i add script to it? or disable it?

    can i add some simple function at the 'X' button (close button) on the browser which will check whether user enter all fields and if not, prompt them to enter.

    (i wanna do this so user cant close the window in half way of the form process)

    or is there anyway to disable it? or open a window without the title bar?

  2. #2
    SitePoint Addict mmanders's Avatar
    Join Date
    Jul 2006
    Location
    Edinburgh, Scotland
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Disabling the use of the close button, assuming it could be done, would be considered bad practice from a usability point of view. A user should always have control of their browser.

    An alternative would be to handle the onunload event and have a confirmation dialog display confirming the user's intention of closing the window.

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,255
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    x button

    Disable it? You definately do NOT want to do that. Users don't like web pages that hi-jack their browser. You can bet they'll never come back.
    Open a window without a title bar? The javascipt open() function accepts several parameters as arguments. But be warned, it is abuse of this function that is responsible for the popularity of pop-up blockers. Be very careful in deciding what functionality you want to "yes" or "no".

    But, it is true that users also get frustrated with filling out a lengthy form and having the info get wiped out because of a mistake. If your form is somewhat complex, it may be better to break it down into more than one page. That way they can "back button" to the previous page and then continue.

    You can use javascript onunload with confirm() but ......

    Think carefully about the pros and cons of using an exit confirm. Users that have accidently closed the browser will be thankful for a chance to continue, but users that truely wanted to exit the page may be annoyed. Although IMO a confirm is much less likely to have a negative effect than a pop-up window.

  4. #4
    SitePoint Addict mmanders's Avatar
    Join Date
    Jul 2006
    Location
    Edinburgh, Scotland
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree with the man from Massachusetts - big no no. Breaking the form into pieces and saving progress as they hit next using sessions or something might be an ideal solution.
    [aside]
    My girlfriend has an inability to pronounce Masachusetts - it's really quite funny!
    [/aside]

  5. #5
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    or is there anyway to disable it?
    No.

    or open a window without the title bar?
    No.

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,869
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The title bar and close button are part of the operating system and the browser has no access to change it. Since all requests from your web page to make changes outside the the page go to the browser there is no way for the page to ask the operating system to change something that the operating system doesn't allow the browser any access to.

    Any attempts to change the operating system or even the browser will greatly annoy your visitors. More importantly the access that would be required to allow web pages to do that would also allow the web pages to request the destruction of the entire content of the computer or the replacement of any file on the computer with a file of the web page owner's choice. This sort of thing used to happen before the security settings were tightened to stop browsers being able to request these changes to the operating system.
    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="^$">


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
  •