Reputation: 15733
In the absence of the download is complete before using the innerHTML will cause pages to load iframe disorder
In the following example, the first Click "openA" (google page), then "openB" (yahoo page), and then "openA", then A window shown on the wrong yahoo page.
The BUG in chrome and IE does not exist under.
How to avoid this problem?
BUG example code:
<HTML>
<HEAD>
<script>
function openA(){
var winObj=document.getElementById("win_A");
if(winObj==null){
winObj=document.createElement('div');
winObj.id="win_A";
winObj.style.position="absolute";
winObj.style.left="0";
winObj.style.top="200";
winObj.style.height="300";
winObj.style.width="300";
winObj.style.border="1px solid red";
document.body.appendChild(winObj);
}
document.getElementById("win_A").innerHTML=("<iframe src='http://www.google.com/'></iframe>");
}
function openB(){
var winObj=document.getElementById("win_B");
if(winObj==null){
winObj=document.createElement('div');
winObj.id="win_B";
winObj.style.position="absolute";
winObj.style.left="350";
winObj.style.top="200";
winObj.style.height="300";
winObj.style.width="300";
winObj.style.border="1px solid red";
document.body.appendChild(winObj);
}
document.getElementById("win_B").innerHTML=("<iframe src='http://www.yahoo.com/'></iframe>");
}
</script>
</HEAD>
<BODY>
<INPUT TYPE="button" VALUE="openA" ONCLICK="openA()"><INPUT TYPE="button" VALUE="openB" ONCLICK="openB()">
<script>document.write("<iframe src=\"http://www.chaozh.cn/Iheeo_pic/200961017195991087.bmp?"+new Date()+"\"></iframe>");</script>
<INPUT TYPE="button" VALUE="Reload" ONCLICK="location.href=location.href;">
</BODY>
</HTML>
</pre>
Upvotes: 1
Views: 793
Reputation: 11
http://www.yozooffice.com/framemix.html there's no need to use a big bmp in IE;
Upvotes: 1
Reputation: 321786
Works fine for me on FF 3.5.3
Managed to reproduce it with a lot of clicking. Seems like a bug in FireFox to me.
Rather than recreating the iframe each time could you just set its .src
?
Upvotes: 0