troubleshooting Question

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

Avatar of dejandejanovic
dejandejanovic asked on
4 Comments2 Solutions925 ViewsLast Modified:
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) {

Open in new window

Thanks in advance for help!
Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
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 2 Answers 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