We have a Point of Sale product that runs in the browser(specifically chrome Kiosk mode). We want to prevent the user from being able to close the window without a pin number. In kiosk mode of course the only way to exit is to either end the process or use alt+f4 so right now our solution is not attatching keyboards to any POS terminals. Just hoping that there may be another solution.
edit: Also to mention I have complete root access on every terminal this web app is being run on. So any chrome flags, etc... can be added.
As mentioned before, I was asking for what ways i could prevent the window from closing all together not simply intercepting unload event and asking for confirmation.
No, you can't disable the close button on any web site. This would be a major security concern. You can, however, use onbeforeunload to ask the user if they really want to leave, but they can still continue to close the window if they desire.
The Window. close() method closes the current window, or the window on which it was called. This method can only be called on windows that were opened by a script using the Window.
There is no way to completely stop it, the best you can do is confirm the leaving.
window.onbeforeunload = function (e) {
var message = "Your confirmation message goes here.",
e = e || window.event;
// For IE and Firefox
if (e) {
e.returnValue = message;
}
// For Safari
return message;
};
Answer from Intercept page exit event
About alt+f4 refer to this: Disable ALT+F4, yes I know it isn't recommended
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With