Home >Web Front-end >HTML Tutorial >Discuss the details after setting the src of iframe to about:blank_HTML/Xhtml_Webpage Production

Discuss the details after setting the src of iframe to about:blank_HTML/Xhtml_Webpage Production

WBOY
WBOYOriginal
2016-05-16 16:40:212087browse

After setting the src of the iframe to 'about:blank', if it is not set to "about:blank", the memory will not be released. You must also use iframe.document.write('');
in order to clear the content, but after this processing, there will still be about 500-1000K of memory left. This is the iframe bug of IE6. Dynamically created iframes always It will consume some memory.

Copy code
The code is as follows:

function clearIframe(id){
var el = document.getElementById(id),
iframe = el.contentWindow;
if(el){
el.src = 'about:blank';
try{
iframe. document.write('');
iframe.document.clear();
}catch(e){};
//The above can clear most of the memory and document node records
//Finally delete this iframe.
document.body.removeChild(el);
} } clearIframe('iframe_id');
Statement:
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