gpt4 book ai didi

javascript - firefox 针对innerHTML iframe 标签的BUG

转载 作者:行者123 更新时间:2023-11-28 02:59:34 25 4
gpt4 key购买 nike

在没有下载完成之前使用innerHTML会导致页面加载iframe紊乱

在以下示例中,首先单击“openA”(google 页面),然后单击“openB”(yahoo 页面),然后单击“openA”,然后在错误的 yahoo 页面上显示一个窗口。

该BUG在chrome和IE下不存在。

如何避免这个问题?

BUG示例代码:

<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>

最佳答案

http://www.yozooffice.com/framemix.html没有必要在 IE 中使用大 bmp;

关于javascript - firefox 针对innerHTML iframe 标签的BUG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1470319/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com