Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

JavaScript: Interrupting Back, Forward and Refresh

Anyway to do this?

11:50 pm on Mar 11, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 8, 2001
votes: 0

OK, so I want to interrupt the click of a back button and display a warning message - "By clicking back you will lose all of the information you have just entered! Do you wish to proceed?" - yes / no

And the same for refresh...

Is this possible? -- purely with javascript.

I can't find anything that says it is...

Thanks for any help :)

PS. This isn't a request for an discussion on hijacking browsers... it's a bad idea. This is a web application situation where back and refresh break the app. I also have don't have full control over the app so redesigning it isn't an option either. Finally I can't hide the toolbar :) - I love this contract ....

[edit]Clarified with purely javascript[/edit]

3:55 am on Mar 12, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member txbakers is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Sept 1, 2001
votes: 0

The built in buttons of the browser such as Back and Refresh can not be overridden. Just as a person can simply close the browser and leave your app. You just have to code for that.

If it's a problem where people lose information by going back, they will learn soon enough not to go back. The user must take some responsibility.

You can code your own back and refresh buttons, which would display a warning, but you can't override the built in browser buttons.