使用html5的audio标签和IE的bgsound添加网页音效。兼容火狐、谷歌、IE6 7 8 ,暂时还不知道IE9、IE10的情况。IE9、IE10支持bgsound 吗?支持的话还蛋疼了,还要处理IE9 10。
待会查查这个问题去。
js代码和html代码如下,
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
$(function(){
$("a").click(function(){
$("#eggs_audio,#eggs_bgsound").attr("src","eggs.wav");
});
});
</script>
<audio src=\'?\' controls autoplay=\'autoplay\' id=\'eggs_audio\' style=\'display:none;\'></audio>
<bgsound src=\'?\' loop=\'1\' autostart=\'true\' id=\'eggs_bgsound\' style=\'display:none;\'>