SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Disabling the back button - getting default msg

    Hey all.

    I am trying to disable the back button but when I do it by calling a JS function on "onunload", I get default messages that I need to suppress. This is primarily in Firefox.

    I copied the following after googling it.

    BEGIN CODE
    var workIsDone = false;
    window.onbeforeunload = confirmBrowseAway;

    function confirmBrowseAway()
    {
    if (!workIsDone)
    {
    var answer = confirm("Please click 'Cancel', then click the 'EXIT' button.")
    if (answer)
    {
    return false;
    }
    else
    {
    return false;
    }

    }
    }
    END CODE

    Any help would be appreciated.

    ...

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You cannot suppress that default message.
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JimmyP View Post
    You cannot suppress that default message.
    Is that for all browsers of just Firefox?

  4. #4
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What if I blanked out the history, would that do it? How do you blank out the history?

  5. #5
    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)
    Quote Originally Posted by Webspeeder View Post
    What if I blanked out the history, would that do it? How do you blank out the history?
    In your browser you can do it from the internet options/preferences. In someone else's browser you can't do it.

    The person who owns the browser has the final say in what web pages can access in their browser and as security reasons for not giving access to various functions grows the browsers are permanently disabling them. You need to assume that if it isn't in your page you may not have access.
    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="^$">

  6. #6
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's fine. I'm just displaying a message telling them to either exit gracefully *or* information may be lost. It's for a browser based app, but it is on an intranet, not the internet.

  7. #7
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Webspeeder View Post
    I am trying to disable the back button ...
    You can't, and if you think you need to, then there is something wrong in your application design.

    If you were submitting a form via post on the previous page, you can use redirect-after-post to prevent the user from resubmitting the form.


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
  •