Disable the X in the Browser

  • Thread starter Thread starter Mike Nooney
  • Start date Start date
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?
 
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
 
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.
 
Back
Top