我有两个iframe,它们都在同一页面上。除了一个具有onload
函数集之外,对两者都做得很少。但是,当我将它们放入页面时,只会加载第一个。如果我切换它们出现的顺序,第二个总是无法显示。两者都可以完美地工作。下面是包含框架的表的代码:
</td>
</tr>
<tr id="gameFrame">
<td>
<iframe id="gameFrame" src="http://en.wikipedia.org/wiki/Special:Random"/>
</td>
<tr>
<tr id="controls">
<td>
<iframe id="goalFinder" onload="getGoal()" src="http://en.wikipedia.org/wiki/Special:Random"/>
</td>
</tr>
</table>
是什么导致第二帧不显示,我该如何解决?
只需为每个 iframe 添加一个结束标签,而不是/>
<table>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<iframe id="gameFrame" src="http://en.wikipedia.org/wiki/Special:Random"></iframe>
</td>
<tr>
<tr id="controls">
<td>
<iframe id="goalFinder" onload="getGoal()" src="http://en.wikipedia.org/wiki/Special:Random"></iframe>
</td>
</tr>
</table>
尝试关闭您的<iframe>
。它不是一个自闭的元素。
<iframe id="gameFrame" src="http://en.wikipedia.org/wiki/Special:Random"></iframe>
<iframe id="goalFinder" onload="getGoal()" src="http://en.wikipedia.org/wiki/Special:Random"></iframe>
演示