兼容chrome和ie的wav音樂播放(Ie7 Ie8 Ie9 均測試過 )


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
<title>aa</title>  
  
  
<script>   
function playSound(){   
//IE放 背景音樂 var snd_ie = document.getElementById('snd_ie'); snd_ie.src = "./alert.wav" //chrome var snd_chrome = document.getElementById('snd_chrome'); snd_chrome.data = "./alert.wav" } function stopSound(){ var snd_ie = document.getElementById('snd_ie'); snd_ie.src = "" var snd_chrome = document.getElementById('snd_chrome'); snd_chrome.data = "" } </script> </head> <body> <bgsound id='snd_ie' src="" loop=-1></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> </html>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM