更改iframe src onchange的下拉列表值 [英] Change iframe src onchange of dropdown value
本文介绍了更改iframe src onchange的下拉列表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以通过按钮单击轻松地更改iframe的源代码。但是无论我尝试什么,我不能使用下拉列表同样的事情。
I am able to change the source of an iframe very easily with a "button" click. But no matter what I try, I can't make the same happen with the use of a dropdown.
这样做:
<html>
<body>
<a href="google.com" target="iframe">google</a>
<iframe name="iframe" src="yahoo.ca"></iframe>
</body>
</html>
但这不是:
<html>
<body>
<form name="change">
<select name="options" target="iframe">
<option><a href="google.com" target="iframe">google</a></option>
</select>
</form>
<iframe name="iframe" src="yahoo.ca"></iframe>
</body>
</html>
任何建议将不胜感激。我发现其他帖子类似,但都涉及使用数组 - 我不相信我应该需要的。
Any advice would be greatly appreciated. I found other posts similar, but all involved the use of arrays - which I don't believe I should need?
推荐答案
你需要使用JavaScript
You need to use JavaScript
<html>
<body>
<form name="change">
<SELECT NAME="options" ONCHANGE="document.getElementById('youriframe').src = this.options[this.selectedIndex].value">
<option>choise</option>
<option value="http://microsoft.com">Microsoft</option>
</SELECT>
<iframe name="iframe" id="youriframe" src="yahoo.ca"></iframe>
</body>
</html>
这篇关于更改iframe src onchange的下拉列表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文