problem
In my current project, the front-end part of the full use of ExtJS based on the "one-page" concept to build. In addition to an HTML as a basic container, it is all JS files (page is implemented by JS file). When the user switches the page, we refactor the previous Page object and then create a new Page object and display it in HTML. Based on this architecture, we also introduced an ActiveX control to present the report. This introduction, the problem comes out: As long as the access to the report control of the existing page, the user Switch 2 times page, IE will crash (ff no problem), the hundred test unhappy.
reason
Because the system design takes into account the release of resources, specialized in the process of the destructor, and no ActiveX pages have no problems. Therefore, the problem must be out of IE on the contained in JS ActiveX control released a problem. After all, in the traditional HTML or JSP, PHP page built in the front-end, ActiveX is a page, as long as the user jumps, the page is unload, and the ActiveX is destroyed; Our system uses the continuous redrawing of an HTML page to achieve the jump, That is, the system will never refresh, there is no unload,activex nature can not be destroyed, resulting in a browser crash.
Solving Method
Knowing the reason, let's think about it. Since IE can't help us destroy ActiveX controls. We'll do it by ourselves:
Copy Code code as follows:
@AcitveXObjectID: The range of nodes to look for, from this node to find the ActiveX to be deleted.
@ContianerID: The ActiveX control ID to remove.
function Activexkiller (Acitvexobjectid,contianerid) {
var Ce=document.getelementbyid (Contianerid);
if (CE) {
var Cce=ce.children;
for (Var i=0;i<cce.length;i=i+1) {
if (Cce[i].id==acitvexobjectid) {
Ce.removechild (Cce[i]);
}
}
}
}
This method is used to kill ActiveX controls. Principle is also simple. is to use the given ActiveX's ID in the DOM to step through the given range of nodes (typically the parent node, container) of the ActiveX control, and manually remove once it is found.
With this killer, we'll be able to fix the ActiveX before the page is redrawn, avoiding the crash.
In addition, there is a special case to be mentioned. is when you put an ActiveX control in a Ext.window. And naively want to let Ext.window in the closing time to help you to the inside of the ActiveX also destroyed, you must meet a condition:
The ActiveX container must be the Ext.window itself.
In other words: If you put the ActiveX control in a Ext.panel, then put it in the Ext.window. Don't expect Ext.window to bring your ActiveX control "Together" when it's closed.
goodluck!