<body> <bgsound id=‘snd_ie‘ src="" loop="loop"> <object id=‘snd_chrome‘ width="0px" height="0px" type="audio/x-wav" data=""></object> <input type="button" value="开始" onclick="playSound()"> <input type="button" value="暂停" onclick="stopSound()"> </body> <script> function playSound() { //IE放 背景音乐 var snd_ie = document.getElementById(‘snd_ie‘); snd_ie.src = "http://10.6.40.46:9999/records/2/voice/20170705/1051/102/20170705233723050.wav"; //chrome var snd_chrome = document.getElementById(‘snd_chrome‘); snd_chrome.data = "http://10.6.40.46:9999/records/2/voice/20170705/1051/102/20170705233723050.wav"; } function stopSound() { var snd_ie = document.getElementById(‘snd_ie‘); snd_ie.src = "" var snd_chrome = document.getElementById(‘snd_chrome‘); snd_chrome.data = "" } </script>
搜了下firefox不支持播放wav文件,大神可以补充
本文出自 “紫枫5966” 博客,请务必保留此出处http://zifeng5966.blog.51cto.com/8763113/1947614
原文地址:http://zifeng5966.blog.51cto.com/8763113/1947614