Show message box when user closes IE

Any javascript requests a message box when a user closes IE? I tried to find the sample code for quite a while, but could not.

thanks in advance George

Here is my html code, but it has the following error. Any ideas?

To protect your security, Internet Explorer restricted this web page to running scripts or ActiveX controls that could access your computer. Click here to find options ...

+3
source share
4 answers

You are looking for an beforeunloadevent.

For example:

function someCloseEvent() {
  return "Any string value here forces a dialog box to \n" +
         "appear before closing the window.";
}

window.onbeforeunload = someCloseEvent;
+7
source

. clientx clientY beforeunload. ...

<script type="text/javascript">

    var myclose = false;

    function ConfirmClose()
    {
        if (event.clientY < 0)
        {
            event.returnValue = 'Any message you want';

            setTimeout('myclose=false',100);
            myclose=true;
        }
    }

    function HandleOnClose()
    {
        if (myclose==true) alert("Window is closed");
    }
</script> onbeforeunload="ConfirmClose()" onunload="HandleOnClose()"
+1

, , . , , . .

+1

Source: https://habr.com/ru/post/1703484/


All Articles