aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Disabling Back and Refresh/Reload button. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Disabling Back and Refresh/Reload button." Watch "Disabling Back and Refresh/Reload button." New topic
Author

Disabling Back and Refresh/Reload button.

Ashwani Yadav
Ranch Hand

Joined: May 23, 2002
Posts: 33
How should I disable my Browser's Back and Refresh/Reload button for both of my browser Ie 6 and Netscape 6.2?
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

You can't...
You always put these line in yor JSP page:

When the use hit the back a new page will com up showing that the page has expired and that the refresh button should be used. When hitting the refresh button the page will be generated again.

/Rene


Regards, Rene Larsen
Dropbox Invite
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
There are a few points it is important to understand about writing applications for the World Wide Web.
  • The first is that whatever people may say, you have no control over what browsers people use to access your applications.
  • The second is that you have no control over how people choose to configure them.
  • The third is that you have no control over what software runs "between" the user's browser window and the code running on your server.
  • The fourth is that once you have served some information to some remote system, they have it, they can do what they want with it, and you can never take it back.


  • With all the above in mind, I hope you are not thinking that somehow preventing the "BACK" and "REFRESH" operations is any form of security or error-protection. All it will do is irritate people and motivate them to try and get round however you have done it.
    Can you tell us a little more about what you want to do this for. Lots of us have built successful web applications facing up to all these issues. We can probably suggest ways of producing an effective system which doesn't need to put heavy limits on what people do with their browsers.
    As a final side note, Rene Larsen's suggestions are a useful way of hinting that a page should alway be refreshed, but I would add that an expiry date of 0 is generally considered a slightly risky choice. There are cache systems out there which erroneously consider a value of 0 as the same as if the header is not present, so it's almost always better to put a positive, but definitely expired, value there (say Midnight, December 31, 1999).


    Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
    Eric Pascarello
    author
    Rancher

    Joined: Nov 08, 2001
    Posts: 15376
        
        6
    Okay now for my turn at this.....
    Want to disable them, then you can remove them from the window by using a pop up...
    You can only remove these items by creating your own window.
    There is a way to disable the back button.
    Look here: http://www10.brinkster.com/A1ien51/Scripts/BackButton.htm
    If you do not know how to create a pop up window look here at my new generator
    http://www10.brinkster.com/A1ien51/scripts/PopUpWinGenV3.htm
    or look at the one in my sig.
    Hope This Helps
    Frank Carver
    Sheriff

    Joined: Jan 07, 1999
    Posts: 6920
    Al Ian wrote:
    you can remove them from the window by using a pop up... Sure, but the user probably still has a right-click menu option to turn them back on again for that window, or he might have disabled pop-up windows alltogether (they are nearly always "spam" commercials). And you've just pissed him off a bit at having to do it.
    There is a way to disable the back button. Sure, but it needs JavaScript enabled and the JavaScript policies set to allow reading/manipulation of the history list. And you've just pissed your user off (who just wanted to look what the previous page said) a little bit more.
    How long before you irritate your users enough that they go somewhere else instead ?
    I'm not denying that these are interesting and potentially useful techniques. I do, however, want people to think about how uers might feel about things which work everywhere else (like the BACK button) being made needlessly difficult for them.
    Please, think of these sort of techniques like pushing your car rather than driving it. It might make sense when you've run out of gas or it won't start, but even though it gets you where you want to go you'd have to be mad to do it by choice.
    And, please tell us a bit more about your application and its need for this. If that car really does need a push, it's easier with lots of people
    Eric Pascarello
    author
    Rancher

    Joined: Nov 08, 2001
    Posts: 15376
        
        6
    People will find out that changing a person's browser will piss certain people off. There are some cases where the programmer has other options to figure out how to get around the problems. I post easy solutions to get to the answer. Most of these people's problems can be solved with cookies, but 1 line of code it better then 70 for people looking for a quick fix. If you looked at my back button page you will see that I tell them that it does not work, but who cares.
    Wish I could start a poll on this page saying if a person would rather get an anwser or a story about ethics. Shouldn't it be a person's choice to use a code and not another members??
    Let them find out that disabling the back button will not bring back people. Maybe disabling the back button on a certain page will keep a person's browser from locking up. (This happened with a person with an applet. If the back button was pressed the browser locked up)
    Smile
    Frank Carver
    Sheriff

    Joined: Jan 07, 1999
    Posts: 6920
    Re-reading my post above, I hope it didn't come over as sarcastic or snide. I've probably been bitten by too many hard to use web sites and web applications, and sometimes I would just like the designers to stop and think a little before casually breaking the browser functionality we are all comfortable with.
    And thanks to Al Ian for the site link. When I do find myself needing to push that car, I know where I'll go for help !
    David O'Meara
    Rancher

    Joined: Mar 06, 2001
    Posts: 13459

    My view is also closely tied to Franks. Most of the problems (in my opinion) tend to stem from people trying to build windows functionality into web-apps. A web app is not a window app, and the more you try to design it that way, the more trouble you'll run into.
    I also tend to take the hardline view, where you should develop applications that follow (and it never works perfectly, but you try) the original HTML and HTTP design. Thin clients, no client functionality, standards based, request/response etc etc.
    Go see my views on the new Flash mega-client in the JSP forum (coughing noises).
    Back/Forward/Refresh issues will always be a problem. It's always been my view (and always will be) that you can't reliably control this and nor should you. It encourages you to build further and further from the 'safety area', and soon you get to applications that only run on your machine...
    Dave
     
    Don't get me started about those stupid light bulbs.
     
    subject: Disabling Back and Refresh/Reload button.