PC3TJ PC3TJ - 2 years ago 88
Javascript Question

Prevent Window Close

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.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download