Repeated jquery references in easyui (tab Memory leakage)

Source: Internet
Author: User

Today, I carefully tested some compatibility issues with easyui and found that the following bug occurs when ie9 ie10 is loaded for the first time. :

After reading it carefully, I guess it is a duplicate reference of the script. I use the iframe framework mode. After logging on to the system, the desktop homepage also loads the same jquery script.

Later, I added a delay of 1 ms to the Code for loading the homepage, and the problem was solved. The Code is as follows:

 

SetTimeout (function (){
$ ("# Tabs"). tabs ('add ',{
Title: 'Personal desktops ',
Content: createFrameByTab ('/home/desktop. aspx '),
IconCls: 'home'
});
}, 1 );

 

 

Now, it may be due to the tab Memory leakage. How can this problem be solved?

 

Easyui source code:

Tab. panel ("options"). tab. remove ();
// Add
Var frame = $ ('iframe', tab );
If (frame. length> 0 ){
Framework0).contentcontactdoc ument. write ('');
Frame [0]. contentWindow. close ();
Frame. attr ('src', "about: blank ");
Frame. remove ();
}
//
Tab. panel ("destroy ");

 

Refer:

SCRIPT5009 error reported by jquery tabs and easyui tabs in IE9
Recently, the Jquery UI Tabs plug-in was used in a project. When a new tag is added, the iframe page is manually appended to tabs, and $ ("# tab") is used in iframe "). tabs ('delete', selectedindex); when the method removes tags, IE9 will report the SCRIPT5009 error. The error code points to jquery. line 3 of js reports that "isNaN" is undefined. isNaN is a JS native function. How can it be undefined? After some research, I finally found out that it was originally caused by iframe because IE had a bug in the collection of iframe elements, in general, you should change the src attribute value of this element to "abort: blank" and manually remove it from the DOM tree. Otherwise, memory leakage will occur. Open the source code of jquery tabs and find that the Tabs plug-in directly removes DIV panels when removing the tag, and does not process iframe. iframe is a sub-element of div panels, direct deletion will cause the above problems, so you can add the following code to modify the source code:

Var ifrm = panls. find ("iframe"); // first find iframe
 
If (ifrm. length> 0) {// when iframe exists
 
Var el = ifrm. get (0 );
 
El.contentdomaindoc ument. write (''); // clear the iframe content
 
El. contentWindow. close (); // prevent iframe Memory leakage
 
Ifrm. attr ('src', "about: blank ");
 
Ifrm. remove ();
 
}
 
Problem solving :)

Web technology sharing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.