Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript IFrame内容交换错误?_Javascript_Html_Firefox_Iframe - Fatal编程技术网

Javascript IFrame内容交换错误?

Javascript IFrame内容交换错误?,javascript,html,firefox,iframe,Javascript,Html,Firefox,Iframe,我有一个包含许多iFrame的网页,包括第三方iFrame,如ad sense和各种共享按钮 在Firefox中,我注意到偶尔这些iframe的内容会被交换,这样你就会在另一个iframe所在的位置看到一个广告感知广告。iframe内容出现的地方似乎完全是随机的。这似乎与缓存有关 有人知道这是什么原因吗,或者我可以采取什么措施来防止这种情况发生吗?一个合理的答案是两个iframe具有相同的名称。我在conkeror(基于firefox)经历过几次这种情况,每次都是名称冲突。我已经为此挣扎了一段时

我有一个包含许多iFrame的网页,包括第三方iFrame,如ad sense和各种共享按钮

在Firefox中,我注意到偶尔这些iframe的内容会被交换,这样你就会在另一个iframe所在的位置看到一个广告感知广告。iframe内容出现的地方似乎完全是随机的。这似乎与缓存有关


有人知道这是什么原因吗,或者我可以采取什么措施来防止这种情况发生吗?

一个合理的答案是两个iframe具有相同的名称。我在conkeror(基于firefox)经历过几次这种情况,每次都是名称冲突。

我已经为此挣扎了一段时间。问题在于firefox及其缓存iframe内容的方式。这也不是随机的。如果不使用iframe,就没有什么办法可以防止这种短缺

您可以使用以下方法重新加载iframes onload:

var reloadIframes = function () {
    var a = window.frames, b = a.length
    while (b--) {
        a[b].src = a[b].src;
    }
}
在广告的情况下,它将导致双重印象,这将违反你的合同

复制此问题的一个简单方法是创建3个html文件

<!--frame1.html-->
<html>
<body>
<h3>frame one</h3>
</body>
</html>

<!--frame2.html-->
<html>
<body>
<h3>frame two</h3>
</body>
</html>

<!--index.html-->
<html>
<body>
<iframe src="frame1.html"></iframe>
<iframe src="frame2.html"></iframe>
</body>
</html>

第一帧
第二帧
在firefox中打开。然后切换第一帧和第二帧

<!--index.html-->
<html>
<body>
<iframe src="frame2.html"></iframe>
<iframe src="frame1.html"></iframe>
</body>
</html>

刷新index.html。在清除缓存之前,不会交换iFrame


mozilla中有一个bug,但目前没有人在处理它。

如果有人在查看,我可以找到bug报告:


已经过去4年了,他们甚至都没有证实这一点。

Mozilla bug报告中描述的解决方法对我很有效:

<iframe src="webpage2.html?var=xxx" id="theframe"></iframe>

<script>
var _theframe = document.getElementById("theframe");
_theframe.contentWindow.location.href = _theframe.src;
</script>

var_theframe=document.getElementById(“theframe”);
_theframe.contentWindow.location.href=\u theframe.src;

此问题可能与您的问题类似

试着把

window.onload = yourcode; 
与车身一起卸载

我有一个关于头部片段的工具提示javascript,其中包含

window.onload = initTip;
但是与我的onload iframe冲突

<body onload = "parent.myframe.location='mypage.html'">

我的解决方案: 删除该window.onload=initTip;从头部部分开始,然后将其放入体内

<body onload = "initTip(); parent.myframe.location='mypage.html'">


在firefox上使用“重新加载”按钮是可行的

你说的“被交换”是什么意思?您是否正在执行刷新/重新加载iFrame的操作?我没有执行任何操作。一帧的内容将加载到另一帧的位置。