troubleshooting Question

How detect if client close browser window from 'taskbar' option? Need someone to check, modify code!

Avatar of dejandejanovic
dejandejanovic asked on
JavaScriptASP.NET
4 Comments1 Solution925 ViewsLast Modified:
Hello,
I have this code to detect when user close browser with 'close button of window'. Works fine for me, but I have found if browser is close from taskbar then javascript is not execute.

Can javascript recognize closing from Windows taskbar?

<script type="text/javascript">
        var myclose = false;
        function ConfirmClose() {
            if (event.clientY < 0) {
                event.returnValue = Do you wish to leave?';
                setTimeout('myclose=false', 10);
                myclose = true;
                        }
              }
        function HandleOnClose() {
            if (myclose == true) {
                location.replace('/contextpath/j_spring_security_logout');
                window.open("logoff.aspx")
            }
        }
    </script>

Thanks in advance for help!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros