javascript - getElementByID work in firefox, but not in IE & Chrome -
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>
the above code can work in firefox, not in ie & chrome.
try this:
<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>
Comments
Post a Comment