【发布时间】:2014-11-28 10:41:03
【问题描述】:
我有以下代码
<script type="text/javascript">
function newSrc() {
var e = document.getElementById("MySelectMenu");
var newSrc = e.options[e.selectedIndex].value;
document.getElementById("MyFrame").src=newSrc;
}
</script>
<iframe name="content" src="" style="position: absolute; left: 0px; top: 28px;" allowtransparency="true" border="0" scrolling="yes" width="100%" frameborder="0" height="90%" id="MyFrame"></iframe>
<select id="MySelectMenu">
<option value="http://www.example.com">Example Site 1</option>
<option value="http://www.example2.com">Example Site 2</option>
</select>
<button onClick="newSrc();">Load Site</button>
这很好用,它根据从菜单中选择的选项加载 iframe 的源代码。现在,我想做的是,在从下拉列表中选择选项并单击“加载站点”按钮后,将选项中的源加载到 iframe 中,然后在说 ...1 后重定向 iframe ONCE第二个。
所以如果选择了示例站点 2,用户点击加载站点,http://www.example2.com 被加载,然后 iframe 被重定向到 http://www.example2.com/admin。
谢谢
【问题讨论】:
-
我可以为您提供解决方案。你介意使用 jQuery 吗?
-
@punkbit 一点也不,我不介意。 jQuery会很好:)
标签: javascript html iframe