Home > Web Front-end > JS Tutorial > Solution to the blank problem when JS loads iFrame

Solution to the blank problem when JS loads iFrame

高洛峰
Release: 2017-01-12 11:17:32
Original
2156 people have browsed it

Various strange problems occurred during the development process using the IE6 browser, which were very difficult. After a lot of effort, the problem was finally solved. I hereby share my problem description and solution on the Script Home platform to help friends who encounter this problem.

1. Blank appears when js loads iframe

iframeID 是加载的 Iframe ID号,修改成自己用的即可。
<iframe name="frames" id="iframeID" src=""/>
setTimeout("document.frames[&#39;"+iframeID+"&#39;].location.href=&#39;"+iurls+"&#39;;",0);
//或
setTimeout("document.frames[&#39;"+iframeID+"&#39;].location.reload();",0);
Copy after login

I think the first method is more appropriate. There is no need to judge the IE version. IE6 and The above versions can be executed smoothly and are only loaded once.

Some netizens said that under IE6, when the src of iframe is close to

2. There is no response when clicking the button to submit the form

setTimeout("form1.submit();",0);
Copy after login

Also use setTimeout to perform delayed execution.

The following is an introduction to how to improve the slow loading of iframes

The solution is as follows:

<iframe name="E" u="http://www.google.com" k="0" src="javascript: void(0)" onload="alert(&#39;加载完成&#39;)"></iframe>
<button onclick="aa(&#39;E&#39;)">google</button>
<script defer="">
function aa(o_w)
{
var _z=document.all(o_w);
if (_z.k==&#39;1&#39;) { alert(&#39;页面已加载&#39;); return; }
_z.k=&#39;1&#39;;
_z.src=_z.u;
}
</script>
Copy after login

The above is the entire content of this article, I hope it will be helpful to everyone!

For more related articles on solutions to the blank problem when JS loads iFrame, please pay attention to the PHP Chinese website!

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