tags:

views:

210

answers:

1

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/'&gt;&lt;/iframe&gt;");
}
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/'&gt;&lt;/iframe&gt;");
}
</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>
A: 

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?

Greg
Are you the download in firefox has been in the time click "openA" and "openB" do?Must be in the "Downloading" to appear when the BUG
Zenofo
my firefox is 3.5.3.
Zenofo
try replace "http://www.chaozh.cn/Iheeo_pic/200961017195991087.bmp"to a big BMP file or page.
Zenofo
I tried only change the src,but still can not work
Zenofo