İbrahim Akgün
İbrahim Akgün

Reputation: 1567

How to Stop Browser from Closing Using ASP.NET or Else?

i got a web page and when browser fire Closing Event i wanna stop it ? How can i do that in asp.net or anyother alternative?

Upvotes: 0

Views: 2462

Answers (4)

Jack Marchetti
Jack Marchetti

Reputation: 15754

There truly is no way to stop the user from closing the browser.

However, you could potentially write some javascript, which would open up a new window when the user leaves the current page (aka closes the browser, clicks on another link).

This would be a bit annoying to your users, and also would probably be blocked by Pop-Up Blockers.

But it is somewhat possible.

Upvotes: 0

nWorx
nWorx

Reputation: 2155

you cannot really stop it, but if needed you can warn the user that session informations or whatever will get lost....

<html>
<script type="text/javascript">
var isdone=false
</script>
<body onbeforeunload="if(!isdone) return 'Do you really want to close!';">
</html>

Upvotes: 3

CJM
CJM

Reputation: 12016

The answer is simple and is similar to this one:

You can't & you shouldn't.

Whatever your problem is, the solution lies elsewhere.

Upvotes: 4

Joel Coehoorn
Joel Coehoorn

Reputation: 415755

You can't, and you shouldn't be able to. How would you feel if StackOverflow were able to prevent you from closing your browser?

Upvotes: 8

Related Questions