在chrome下没问题,ie(Win8,IE10), 只有第一次点击的单词才有发音,点击其他的还是发第一次点击的单词
<html> <head> <title></title> <script type="text/javascript"> function PlayWordEn(obj) { var text = obj.value; document.getElementById(‘test‘).innerHTML = ‘<source src="http://dict.youdao.com/dictvoice?audio=‘+text+‘&type=1" type="audio/mpeg">‘; document.getElementById(‘test‘).play(); } function PlayWordUs(obj) { var text = obj.value; document.getElementById(‘test‘).innerHTML = ‘<source src="http://dict.youdao.com/dictvoice?audio=‘+text+‘&type=2" type="audio/mpeg">‘; document.getElementById(‘test‘).play(); } </script> </head> <body><p> <button type="button" onclick =‘PlayWordEn(this)‘ onmouseover=‘PlayWordEn(this)‘ value="one">one</button> <button type="button" onclick =‘PlayWordEn(this)‘ onmouseover=‘PlayWordEn(this)‘ value="two">two</button> </p> <video style="display:none;" controls="" id="test" name="media"> </video> </body> </html>
时间: 2024-11-07 10:51:16