New back button handling feature
IntraWeb 14.0.27 includes a new feature to prevent the back button usage in IntraWeb applications.
Before explaining how to use it and what it can do for you, please have two things in mind:
a) The browser back button just CAN’T be disabled in any way. There is no API that allows you to do that.
b) You just CAN’T prevent the user from accessing any browser history entry
Having said that… IntraWeb 14.0.27 implements a new experimental feature to prevent back button usage in a IntraWeb applications. There is a new property in TIWServerController class named BackButtonOptions:
- Mode: TIWBackButtonMode = (bmInterceptGlobal, bmInterceptForm, bmEnable, bmDisableCompat)
- bmInterceptForm: When set, IntraWeb will check for IWForm.PreventBackButton property. If this property is true, then it will generate code to prevent back button usage
- bmEnable: When set, IntraWeb will not generate any code to prevent back button usage
- bmDisableCompat (default): When set, IntraWeb will use the same code used in previous IntraWeb versions when ServerController.HistoryEnabled = False
- ShowMessage: boolean, default false. When TRUE, IntraWeb will show an alert message when it detects that back button has been pressed
- WarningMessage: string. Allow the customisation of the warning message used when ShowMessage is TRUE.
Example of the warning message when the user clicks on the back button:
There is a third thing that you must have in mind, besides (a) and (b) above:
c) There is no fail-proof way to prevent going back to a previous page.
During a long research about how back button works and what can be done to handle it better in a web application I found a funny comment, something like: “If your life depends on blocking the back button, redesign your application or accept the fact that death is inevitable”. I guess it says all 🙂
Nevertheless, this feature works quite nicely in all major browsers supported by IntraWeb XIV, including: Internet Explorer, Firefox, Chrome, Safari and Opera.