2

Possible Duplicate:
Disable browser's back button

Is there any way to disable browser(specifically IE) BACK button, FORWARD button, REFRESH button by javascript. So that, when ever any user will click on any button nothing will happen.

Community
  • 1
  • 1
Suresh
  • 5,687
  • 12
  • 51
  • 80
  • You don't require a button to refresh the screen. User can press F5 key to refresh the screen. Why do you want to disable the refresh? – Amit Rai Sharma Nov 09 '11 at 17:34
  • I am curious as well to know why you want to disable the refresh button? – Garvin Nov 09 '11 at 17:39
  • 2
    No, that's impossible. We don't want to get stuck at a page. – Rob W Nov 10 '11 at 11:15
  • It is too much trespassing into client's place. Not possible. – Kangkan Nov 10 '11 at 11:18
  • Except this one is IE-specific, in case it changes the equation in some way. – T.J. Crowder Nov 10 '11 at 11:33
  • I want to know this as well. I have a page where an optional set of audio tracks is being streamed. To solve the problem with navigation stopping the playback I used AJAX for everything on the page, literally everything. All page requests, all form submissions, everything is done with AJAX, therefore I don't want the visitor to be able to mistakingly hitting the back button. – Christian Lundahl Nov 14 '12 at 18:18

2 Answers2

5

No, you cannot reliably, reasonably do that. Even IE's "kiosk mode" allows back, forward, and refresh (via keyboard shortcuts).

On an actual web page (a real page out on the web), disabling back/forward/refresh would of course be extremely inappropriate behavior and I assume that's not what you're trying to do. (Instead, use history libraries and such to ensure your page/web app actually works with the back and forward buttons to do what the user expects.)

Mind you, if you provide a link that opens a new window (which will probably actually end up being a new tab in most modern browsers), your page will be the first page in that window's history and so the Back button will automatically be disabled. And if your page doesn't offer any links anywhere else, it'll stay that way. And if the user hasn't gone Back, by definition they can't go Forward. Nothing you can do about Refresh, though.

If you have a genuine reason for actually disabling those actions (some kind of intranet application, that sort of thing), you'll probably have to distribute an actual application (for instance, .Net app via No Touch Deployment or similar) that incorporates a web browser control, which gives you the HTML/CSS/JavaScript environment but with dramatically higher control over that environment.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
0

As far as I know, you can't modify the buttons in a browser with scripts.

Since you're working with IE, you may be able to use either VBScript or JScript, but I doubt you'll be able to disable the reload button.

More reading:

http://www.webdeveloper.com/forum/showthread.php?t=62177

Tim
  • 4,051
  • 10
  • 36
  • 60