【发布时间】:2015-07-30 16:18:02
【问题描述】:
我有一个带有下拉列表的 HTML 页面,当我选择一个选项时,会打开一个包含另一个 HTML 页面的 iframe。在第二个 HTML 页面内我有按钮,当我单击该按钮时,我想打开一个链接(在 iframe 内)。当我只运行第二页时它正在工作,但是当我运行第一页(带有下拉列表)时它不再工作了。
有谁知道为什么会发生这种情况,我该如何解决?
这是第一页的代码示例:
function Ex(form) {
var myindex = Example.drop.selectedIndex
if (Example.drop.options[myindex] != "0") {
window.open(Example.drop.options[myindex].value, target = "iframe1");
}
}
<form name="Example">
<select name="drop" onchange="Ex(this.Example)">
<option value="about:blank">Select something...</option>
<option value="Page1.html">Page1</option>
<option value="Page2.html">Page2</option>
<option value="Page3.html">Page3</option>
</select>
<iframe id="iframe1" name="iframe1" src="about:blank" align="top" height="900" width="1000" style="border:none; "></iframe>
</form>
下面是在 iframe 中打开的页面之一的代码示例:
<img src="http://focusdesignz.com/wp-content/uploads/2015/07/picture_1436728897.jpg"/>
<input type="button" onclick="location.href='http://www.google.ro'" value="Some Button"/>
【问题讨论】:
-
它完全打开了吗?可能是因为 Google 不允许您在 iframe 中打开,它会中断它?
-
@putvande 现在可以使用了。这是谷歌的错。 :)
标签: javascript html iframe