我该如何使用:
<select name="menu1">
<option value="http://www.espn.com">ESPN</option>
<option value="http://www.cnn.com">CNN</option>
<option value="http://www.abcnews.com">ABC</option>
<option value="http://www.cbsnews.com">CBS</option>
<option value="http://www.foxnews.com">FOX</option>
</select>
<script type="text/javascript">
var urlmenu = document.getElementById( 'menu1' );
urlmenu.onchange = function() {
window.open( this.options[ this.selectedIndex ].value );
};
</script>
并在iframe name =“viewbox”中打开这些链接?
非常感谢!
答案 0 :(得分:1)
试试这个
<script type="text/javascript">
var urlmenu = document.getElementById( 'menu1' );
urlmenu.onchange = function() {
var iframe = document.getElementById( 'iframe_id' );
iframe.src = this.options[ this.selectedIndex ].value ;
};
</script>
答案 1 :(得分:0)
var el = document.getElementById("viewbox");
el.setAttribute('src', this.options[this.selectedIndex].value);
答案 2 :(得分:0)
试试这个
<强> HTML 强>
<select id="my_slect">
<option value="http://www.espn.com">ESPN</option>
<option value="http://www.cnn.com">CNN</option>
<option value="http://www.abcnews.com">ABC</option>
<option value="http://www.cbsnews.com">CBS</option>
<option value="http://www.foxnews.com">FOX</option>
</select>
<iframe id="ifr"></iframe>
<强>脚本强>
$('#my_select').change(function() {
var url = $('#my_select :selected').val();
$('#ifr').attr('src', url);
});