function change1() {
document.getElementById("video").src = document.myvid1.vid_select.options[document.myvid1.vid_select.selectedIndex].value
}
<form name="myvid1">
<select id="vid_select" onChange="change();">
<option value="http://www.youtube.com/v/nN8Si5LKyY?autoplay=1">Test1</option>
<option value="http://www.youtube.com/v/CdKUtZIDzEg?autoplay=1">Test2</option>
</select>
</form>
<object width="650" height="450">
<embed id="video" src="http://www.youtube.com/v/IiJx4a1cxRk" type="application/x-shockwave-flash" width="650" height="450" />
</object>
以上代码可以在Firefox中使用,但不能在IE&amp;铬。
答案 0 :(得分:2)
试试这个,以避免任何潜在的浏览器特定选择器混淆:
<script>
function change(newsrc) {
document.getElementById('video').src = newsrc;
}
</script>
<form name='myvid1'>
<select id='vid_select' onchange='change(this.value)'>
<option value="http://www.youtube.com/v/nN8Si5LKyY?autoplay=1">Test1</option>
<option value="http://www.youtube.com/v/CdKUtZIDzEg?autoplay=1">Test2</option>
</select>
</form>
<object width='650' height='450'>
<embed id="video" src="http://www.youtube.com/v/IiJx4a1cxRk" type="application/x-shockwave-flash" width="650" height="450" />
</object>
答案 1 :(得分:1)
试试这个:
<script type="text/javascript">
function change()
{
var html = '<object width="650" height="450"> <embed id="video" src="';
html += document.myvid1.vid_select.options[document.myvid1.vid_select.selectedIndex].value;
html += '" type="application/x-shockwave-flash" width="650" height="450"/>';
document.getElementById("div-video").innerHTML = html;
}
</script>
<form name="myvid1">
<select id="vid_select" onChange="change();">
<option value="http://www.youtube.com/v/IiJx4a1cxRk">Test1</option>
<option value="http://www.youtube.com/v/CdKUtZIDzEg?autoplay=1">Test2</option>
</select>
</form>
<div id="div-video">
<object width="650" height="450">
<embed id="video" src="http://www.youtube.com/v/IiJx4a1cxRk" type="application/x-shockwave-flash" width="650" height="450" />
</object>
</div>