Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I am using Asp.net with VS2008.
I need to closing event in browser control box using java script.(such as minimize,maximize or close).
is this possible to find closing event for control box in web browser.

pleas give me suggestion or idea ..

Regards
Mukesh
Posted
Updated 4-Jul-13 23:14pm
v2

This link may be helpful to you
http://forums.asp.net/t/1832024.aspx/1[^]
 
Share this answer
 
There is a non-standard onbeforeunload function you can use to detect if the user is leaving the page. It works in almost all the browsers except Opera (it follows W3C standards strictly). The problem with this function is that it will also annoy users when any external link is clicked or the form is submitted. You may use jQuery and do some code-tweaking to avoid it. Try following example:

ASP.NET
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        window.onbeforeunload = function () {
            return "Are you sure you want to leave this page?";
        };
        $(document).ready(function () {
            $('a[rel!=ext]').click(function () { window.onbeforeunload = null; });
            $('form').submit(function () { window.onbeforeunload = null; });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <a href="http://www.google.com" rel="ext">Redirect with message</a>
        <br />
        <a href="http://www.google.com">Redirect without message</a><br />
        <asp:Button ID="btnSave" runat="server" Text="Save" />
    </div>
    </form>
</body>
</html>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900