Disable the X in the Browser

M

Mike Nooney

How do I disable the "X" in the upper right hand corner of my Web Page.
This is not for a windows form, but rather a web application. What I really
need is to stop the user from unloading the page, if certain data is not
present on the page. I know I should not use the Page_Unload event for
this. I wouild like to disable the Close Button, or putting some extra
validation behind a certain event, which event I am not sure. Any help
would be appreciated?
 
J

Jerry III

Forget about disabling the user to close the browser, it's not going to
happen. But if you tell us why would you want to do that we might be able to
offer you some solutions.

Jerry
 
D

DWinter

You can't disable the X button without making the page fullscreen, and even
then they can alt+F4 or ctrl+W the page.
You can't keep them from closing the page, but you can warn them with a
client script

<script for=window event=onbeforeunload language=javascript>
if(!YourValidation)
event.returnValue="Your Warning";
</script>

This will pop up a dialog warning them they are navigating away from the
page because of some reason, but you can't keep them from closing a page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top