Releasing JavaScript ActiveXObject ()?

I call C # COM component using javascript: keystore = new ActiveXObject("RBCrypto.KeyStore");. I noticed that this instance remains until I exit the browser. Is there a way to β€œrelease” this object when the user leaves the page? I am currently using:

window.onunload=function() //when a user leaves the page close the keystore
{
     if(keystore != null)
     {
         try
         {
            keystore.closeKeyStore(); //method in keystore
            delete keystore;
         }
         catch(err) { alert(err.description); }
     }  
}

But the COM object is still in place. Any ideas?

+3
source share
2 answers

I know it's a bit late to answer. "Until later than never"

, : "Application.Quit();". Object COM/OLE/ActiveX null. , return Application!= Null Quit();

...

try
{
    keystore.closeKeyStore();
    delete keystore;
    keystore = null;
    CollectGarbage(); 
}
catch(err)
{
    alert('freeing ActiveXObject via javascript'+ err.description);
}
+1

,

keystore.Application.Quit();

http://www.c-point.com/javascript_tutorial/jsobjActiveXObject.htm

for (k in elm) {
            try {
                elm[k] = null;
            }
            catch (e) {
            }
        }
}

, HTML, , .

+1

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


All Articles