Preventing users to click the "X" to close the window

Hi folks,

I need a way (javascript or other) to prevent the users to close (with the X or File | Close) a window. They will need to click on a specific button to exit the application.

Thanks

Remi

Subject: Preventing users to click the “X” to close the window…

Bonjour Remi.

We did not succeed in preventing our users to close the window with the X. So we chose instead to catch this event with the onUnload event. We had to do some stuff with the document (unlocking it for other users, etc.) so we decided to call an agent to do it.

It worked fine for us.

HTH

Subject: RE: Preventing users to click the “X” to close the window…

In another thread, Remi explained that this is an unreliable method. Using a scheduled cleanup agent does work reliably, but it means “leasing” documents – giving the user, say, an hour maximum to do what they want to do, then preventing a submission unless the lease is renewed.

Subject: Preventing users to click the “X” to close the window…

I’ve never tried it but…

You could put code in the queryopen and queryclose (database script should be enough, but you could do it in the views and docs as well). In the queryopen, it sets an environment variable. Then put code in the queryclose that checks for that variable, and won’t allow queryclose to continue if it is there. Then your button could contain code to remove that envar, then perform the exit.

Subject: RE: Preventing users to click the “X” to close the window…

That’s my fault… I should have said from a Web Browser… I apologize for the confusion.

Any idea in doing that?

Subject: RE: Preventing users to click the “X” to close the window…

Yeah – don’t try. EVER. If you can’t manage your clean-up server-side, then don’t write web applications.

There is nothing you can do to actually prevent a window from closing reliably, and any user with an ounce of sense will immediately assume that you are trying to cause a malware install if you force them to click on anything to navigate away from or close your page.