Ajax下拉/最后一个选项更改Iframe
Ajax Drop Down/Last Option Changes Iframe
我现在有这个脚本,它完成了我现在想要它做的一切。它有一个下拉菜单,你可以选择goTo,你也可以选择维基百科或其他网站的列表。从那里,它将把当前存在的iFrame(例如微软)的值更改为另一个网站(例如维基百科)。
然而,我的问题是,在更改选项时,它会关闭连接并显示一个空白页面,直到我选择维基百科。我该如何解决此问题?这是我当前的代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="style.css" rel="stylesheet" />
<script src="http://code.jquery.com/jquery-2.0.3.min.js" data-semver="2.0.3" data-require="jquery"></script>
<script type="text/javascript" src="http://www.appelsiini.net/projects/chained/jquery.chained.js?v=0.9.10"></script>
<script>
function goToPage763(mySelect)
{
PageIndex2=mySelect.selectedIndex;
{
if
(
mySelect.options[PageIndex2].getAttribute('href') != "none"
)
{
//this is the key code in the JavaScript to open the new page in
//the iframe:-
frames['iframe2'].location.href = mySelect.options[PageIndex2].getAttribute('href');
}
}
}
// Add your javascript here
$(function(){
$("#size").chained("#color");
});
</script>
</head>
<body>
<form name="form763">
<select class="form-control" id="color">
<option value="">choose options</option>
<option value="27">Goto</option>
<option value="26">Nothing</option>
</select>
<select class="form-control" id="size" name="select763" size="1" onchange="goToPage763(this.form.select763)">
<option value="">choose options</option>
<option value="27" class="27" href="http://www.wikipedia.com">Wiki</option>
<option value="26" class="26">Nothing</option>
</select>
</form>
<iframe name="iframe2" src="http://www.microsoft.com" align="top" height="800px" width="95%" align="middle">
</body>
</html>
看看这是否能解决问题
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"
data-semver="2.0.3" data-require="jquery"></script>
<script>
function goToPage763(mySelect){
frames['iframe2'].location.href = $(mySelect).val();
}
</script>
</head>
<body>
<form name="form763">
<select class="form-control" id="size" name="select763"
size="1" onchange="goToPage763(this)">
<option value="">choose options</option>
<option value="http://www.wikipedia.com">Wiki</option>
<option value="http://www.microsoft.com">Microsoft</option>
<option value="https://www.wiktionary.org/">Wiktionary</option>
</select>
</form>
<iframe name="iframe2" src="http://www.microsoft.com" align="top"
height="800px" width="95%" align="middle">
</body>
</html>
相关文章:
- 在新选项卡中打开iframe源
- 如何防止iframe中的链接在新选项卡中打开
- Facebook iFrame选项卡-滚动到顶部
- 在iframe内的新选项卡/窗口中打开
- Ajax下拉/最后一个选项更改Iframe
- 通过选择框“选项”更改 Iframe SRC
- 关于 iframe 的替代选项
- 从iframe更改按钮click上的jquery当前选项卡
- 模拟IFrame中的单击,以便打开一个新选项卡
- iframe链接以新选项卡的形式打开浏览器
- 如果iframe页面使用_parent target,请在新选项卡中打开iframe
- 重新加载iframe会打开新的选项卡-Firefox 21.0
- 两个窗口或选项卡之间的跨文档消息传递,而不是iframe
- 使用超时循环将数据加载到iframe的更好选项
- 如何设置flowplayer全屏选项为false(不是iframe)
- 使用jQuery选项卡刷新加载到iframe中的html
- 通过Javascript在各种浏览器窗口/选项卡中维护iFrame页面的状态
- 隐藏Iframe刷新Ajax选项
- 是否可以将iFrame选项卡添加到现有的Facebook页面?
- TinyMCE媒体插件中的iFrame选项