用select控件控制iframe中网页内容
<select>
<option value="1">新浪</option>
<option value="2">搜狐</option>
<option value="3">163</option>
</select>
<iframe id="iframe1"src="http://www.sina.com.cn" name="iframe1" width="200" marginwidth="0" height="160" marginheight="0" scrolling="no" frameborder="0"> </iframe>
想在选择选项后,iframe中的内容自动切换到新的页面,如何实现?
问题点数:20、回复次数:3Top
1 楼kangqin(小康)回复于 2006-03-07 14:46:29 得分 20
<body>
<select onchange="jumpto(this.value)">
<option value="http://sina.com.cn">新浪</option>
<option value="http://sohu.com">搜狐</option>
<option value="http://163.com">163</option>
</select>
<iframe id="iframe1"src="http://www.sina.com.cn" name="iframe1" width="200" marginwidth="0" height="160" marginheight="0" scrolling="no" frameborder="0"> </iframe>
<script type="text/javascript">
function jumpto(url)
{
var obj=document.getElementById("iframe1");
obj.src=url;
}
</script>
</body>Top
2 楼javaCoffee33(EastenStar)回复于 2006-03-07 15:19:36 得分 0
同意楼上的,代码拷贝
<body>
<select onchange="jumpto(this.value)">
<option value="http://sina.com.cn">新浪</option>
<option value="http://sohu.com">搜狐</option>
<option value="http://163.com">163</option>
</select>
<iframe id="iframe1"src="http://www.sina.com.cn" name="iframe1" width="200" marginwidth="0" height="160" marginheight="0" scrolling="no" frameborder="0"> </iframe>
<script type="text/javascript">
function jumpto(url)
{
var obj=document.getElementById("iframe1");
obj.src=url;
}
</script>
</body>
Top
3 楼evaporate()回复于 2006-03-07 16:15:20 得分 0
多谢~Top




