First, some clarifications of my requirements:
- To prevent the user from closing browser or tab (both are treated similarly).
- Note that browser close is different from browser exit. Browser close is done using the "X" button, while browser exit is done using File>Close or Alt+F4 keys.
- JS can only catch browser close event.
- URL refresh was also to be treated as close.
- However, navigation using anchor, buttons or any other DHTML was to be ignored.
- Tested on IE8 and Firefox 3.5.