用js播放声音

时间:2021-09-22 09:20:08
<SCRIPT type="text/javascript">
if(-1 != navigator.userAgent.indexOf("MSIE"))
{
    document.write(' <OBJECT id="Player"');
    document.write(' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"');
    document.write(' width=0 height=0 > <param name="URL" value="5.wav" /> <param name="AutoStart" value="false" /> </OBJECT>');
}
else
{
    document.write(' <OBJECT id="Player"');
    document.write(' type="application/x-ms-wmp"');
    document.write(' autostart="false" src= "5.wav" width=0 height=0> </OBJECT>');
}
</SCRIPT>
<input type=button value="Play" onclick="Player.controls.play();" />
<input type=button value="Stop" onclick="Player.controls.stop();" />