-1

Possible Duplicate:
Disabling Back button on the browser

Hi Guys, I need to disable the backbutton of browser window.When I click on backbutton,I need to show one message using alert or other means.Any one can help me

Community
  • 1
  • 1
user42348
  • 4,181
  • 28
  • 69
  • 98

3 Answers3

5

you can't make the user stay on your page, but you can give a yes/no prompt first, though.

read around Is there a way to determine that the browser window was closed?

Community
  • 1
  • 1
andyk
  • 10,019
  • 10
  • 36
  • 41
4

Short answer: don't.

There's something wrong with the design if you have to do this.

alok
  • 1,218
  • 1
  • 12
  • 29
  • 2
    There are times when you need to show the prompt each time user navigates away from the page, this could be the case. For example if the page manages some list where you put elements and have to save them in the end, you could show "Are you sure you want to exit, you changes are not saved" message. – bezmax Dec 17 '08 at 07:42
  • yup, I agree with Max. Gmail did a great job with this. – andyk Dec 17 '08 at 07:50
2

I HATE it when web pages do this. I'd suggest another way of approaching the usability of your page first.

barfoon
  • 27,481
  • 26
  • 92
  • 138