Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1257
  • Last Modified:

Disable Mouse Back button with javascript

Mouse Back Button: Question:
Hi all,

Have an application where I need to disable where back is used. I currently disable toolbars, disable right click and disable the backspace key, my mouse has 5 buttons and one of these goes back.

Is there a way to stop this from going back?  I have looked everywhere and can't seem to find a valid solution

Thanks,
John
0
PlacesForPeople
Asked:
PlacesForPeople
1 Solution
 
silemoneCommented:
you can't truly disable back button...you can make it where the page can't go backwards though...the only true way to disable this is to open a new window where there is no where to go back to...
0
 
bradl3yCommented:
I don't think there would be a valid way to do this 100% of the time. The back button is a feature of the browser that can not be disabled. It can be hidden, but many browsers also have other keyboard short cuts for the back button, and these days, most browsers will not allow you to disable right click.

But, there is a way that seems to work somewhat:

We will have PageA and PageB. PageA is simply a blank page that will immediatly redirect to PageB. PageB is your page with the actual content. When the user tries to go back, they go back to PageA, which in turn will immediatly redirect them back to pageB.

If your concerns for this deal with an AJAX application, you can use anchors to make the back and forward buttons function as you would expect. Every time something changes in the application, you need to "redirect" to the same page with an anchor at the end that represents the current state (url.com/index.php#tab_options). When a browser redirects to the same page with an anchor attached, most browsers will NOT reload the page, and all of the anchors used will show up in the back/forward history.
0
 
bradl3yCommented:
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
silemoneCommented:
the only way as stated is to either call page in new window...and close old


http://www.hunlock.com/blogs/Mastering_The_Back_Button_With_Javascript
0
 
silemoneCommented:
read the last couple headers:  If you truly want to control history which the back button is tied to...
0
 
silemoneCommented:
again:  another example:

http://www.irt.org/script/311.htm
0
 
silemoneCommented:
and finally this solution sort of works, but it has its faults too...

http://www.boutell.com/newfaq/creating/backbutton.html
0
 
DJDecayCommented:
Impossible to completely disable the back button. Depends on the client (Browser) executing the code, and on the fact that Java Script is enabled and no proxy exists that will filter out the code.

Think of another way, unless you know that the client is IE 7 for example for internal use.

If you're writing merchant processing code, deal with form "repost" (duplicate order submission) on a transactional level (data layer and db), not on the client level.


0
 
PlacesForPeopleAuthor Commented:
Thanks for all of your comments.  I will look for a work around through some of the links you have sent through.

At the minute our browser is IE6 but will no doubt be IE7 by some time next year.  I didn't think there would a way to completely remove the back function but it looks like it isn't possible to completely control the events on an internet mouse.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now