Javascript Play Sound (Wav, MP3, Etc) In One Line
Alright, enough with the 10 page tutorials from 2006 describing detailed
browser-specific implementation tricks to get sound playing. Google
needs a refresh. In my experience in the 2010′s, here’s all you need to
do to make a simple sound play in your web page:
Step one: add an element to your page
<div id="sound_element"></div>
Step two: play a sound via that element
document.getElementById("sound_element").innerHTML= "<embed
src='"+sound_file_url+"' hidden=true autostart=true loop=false>";
原文链接:http://www.rockywang.info/?p=711
browser-specific implementation tricks to get sound playing. Google
needs a refresh. In my experience in the 2010′s, here’s all you need to
do to make a simple sound play in your web page:
Step one: add an element to your page
<div id="sound_element"></div>
Step two: play a sound via that element
document.getElementById("sound_element").innerHTML= "<embed
src='"+sound_file_url+"' hidden=true autostart=true loop=false>";
原文链接:http://www.rockywang.info/?p=711