Solve the problem that the IFrame object memory is not released in IE browser, ieiframe

Source: Internet
Author: User

Solve the problem that the IFrame object memory is not released in IE browser, ieiframe

Recently, the project team found that if the showModalDialog pop-up window contains an IFrame object, the memory resources occupied by the IFrame object will not be released after the form is closed. After the pop-up is closed multiple times, the memory usage of the IE browser can exceed several hundred mb. In severe cases, the IE browser reports an error and cannot close it. You can only restart the browser by killing the process. This problem also exists in the open pop-up mode after testing.

In the IE 8 browser, the memory usage of open and showModalDialog is different:

The window shown in the openmethod occupies an independent icycler.exe process;

Showmodaldialogthe pop-up window uses the same icycler.exe process as the parent window;

After searching, it is found that the solution is to delete the IFrame object from the form before the form is closed. The Code is as follows:

<span style="font-size:18px">var el = document.getElementById("scanIf");el.src="";el.contentWindow.document.write('');el.contentWindow.document.clear();var p = el.parentNode;p.removeChild(el);</span>

However, there are two limitations during the test:

1. If el. src has not been executed, execute the following statement. If IFrame contains cross-origin content, a message indicating no permission is displayed;

2. The form is closed faster than the script execution, and the memory is still not released;

After modification, the final script is as follows:

<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN"> <HTML> <HEAD> <TITLE> </TITLE> <BODY onbeforeunload = "return unloadHandler (); "> <IFRAME id =" scanIf "width =" 800px "height =" 600px "src =" http://www.baidu.com "> </IFRAME> <SCRIPT type =" text/javascript "> function unloadHandler (notip) {// Audit Event document when the window is closed. getElementsByTagName ("BODY") [0]. onbeforeunload = null; var el = document. getElementById ("scanIf "); If (el) {el. src =" "; setTimeout (cycleClear, 100); return" Tip: Click the cancel button. The current window will be closed automatically. ";}Return true;} function cycleClear () {try {var el = document. getElementById ("scanIf"); if (el) cancel.content?#document.write(''{%el.content;{doc ument. clear (); var p = el. parentNode; p. removeChild (el);} window. close () ;}catch (e) {setTimeout (cycleClear, 100) ;}// window. onunload = unloadHandler; </SCRIPT> <input type = "button" value = "remove" onclick = "unloadHandler ();"> </BODY> </HTML>

If the iframe is disabled and the memory cannot be released under IE, kneel down to the solution

If flash exists in your iframe content, it is not necessarily an iframe problem.

GENERAL: cif. parentNode. removeChild (cif); can solve the problem
 
A webpage shows that the browser does not support iframe. What should I do ??

No! IE supports Iframe! Is it a browser setting problem!

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.