Home > Web Front-end > JS Tutorial > Solution to the crash problem caused by using ACTIVEX control in EXTJS_extjs

Solution to the crash problem caused by using ACTIVEX control in EXTJS_extjs

WBOY
Release: 2016-05-16 18:31:03
Original
1182 people have browsed it
Problem
In my current project, the front-end part is completely built using EXTJS based on the "One-Page" concept. Except for an HTML as the basic container, it is all JS files (the page is implemented by JS files). When the user switches pages, we destruct the previous page object, then create a new page object and display it in HTML. Based on this architecture, we also introduced an ActiveX control for displaying reports. With this introduction, a problem arises: as long as the page where the report control exists is accessed, and the user switches pages twice, IE will crash (FF does not have this problem), and it will not work after repeated attempts.
Reason
Because the system was designed with resource release in mind, and the destruction part has been specially handled, and there is no problem with pages without ActiveX. Therefore, the problem must be that IE releases the ActiveX control contained in JS. After all, in traditional front-ends built with HTML or JSP or PHP pages, ActiveX belongs to the page. As soon as the user jumps and the page is Unloaded, the ActiveX in it will be destroyed; while our system uses continuous Redrawing an HTML page to achieve a jump means that the system will never be refreshed, and there will be no Unload. ActiveX will naturally not be destroyed, causing the browser to crash.
Solution
Now that we know the reason, we will think of a solution. Since IE cannot help us destroy ActiveX controls. We can just do it ourselves:
Copy code The code is as follows:

//@AcitveXObjectID: The node range to be searched is used to search for the ActiveX to be deleted from this node.
//@ContianerID: ID of the ActiveX control to be deleted.
function ActiveXKiller(AcitveXObjectID,ContianerID){
var ce=document.getElementById(ContianerID);
if (ce){
var cce=ce.children;
for(var i= 0;iif(cce[i].id==AcitveXObjectID){
ce.removeChild(cce[i]);
}
}
}
}

This method is used to kill ActiveX controls. The principle is also simple. It is to use the given ActiveX ID in the Dom to search step by step within a given node range (usually the parent node or container of the ActiveX control), and once found, manually remove it.
With this Killer, we can take care of ActiveX before redrawing the page to avoid crashes.
In addition, there is a special situation to mention. That's when you place an ActiveX control in an Ext.Window. If you naively want Ext.Window to help you destroy the ActiveX inside when it is closed, you must meet a condition:
The container of ActiveX must be Ext.Window itself.
That is to say: if you put the ActiveX control in an Ext.Panel, and then put it in Ext.Window. Don't expect that Ext.Window can take your ActiveX control "with it" when it is closed.
GoodLuck!
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template