if (!!window.ActiveXObject || "ActiveXObject" in window){
alert("是ie");
}else{
alert("不是ie");
}
谷歌
<div style="display:none;"><video id="yinxiao" autobuffer="true"><source src="plug-in/mp3/smsuccess.wav" ></video>
</div>//提示声音
function f_remind(){var yinxiao = document.getElementById('yinxiao') ,tolF1 =0; //总时长//播放yinxiao.addEventListener("loadedmetadata", function(){tolF1 = yinxiao.duration;//获取总时长});yinxiao.play();}
谷歌,ie
<script type="text/javascript">
playSound();
function playSound(){var borswer = window.navigator.userAgent.toLowerCase();if ( borswer.indexOf( "ie" ) >= 0 ){//IE内核浏览器var strEmbed = '<embed name="embedPlay" src="plug-in/mp3/smsuccess.wav" autostart="true" hidden="true" loop="false"></embed>';if ( $( "body" ).find( "embed" ).length <= 0 )$( "body" ).append( strEmbed );var embed = document.embedPlay;//浏览器不支持 audion,则使用 embed 播放embed.volume = 100;//embed.play();这个不需要}else{//非IE内核浏览器var strAudio = "<audio id='audioPlay' src='plug-in/mp3/smsuccess.wav' hidden='true'>";if ( $( "body" ).find( "audio" ).length <= 0 )$( "body" ).append( strAudio );var audio = document.getElementById( "audioPlay" );//浏览器支持 audionaudio.play();}}
</script>
谷歌,ie
<div id="audioDiv" style="display: none;"></div>
<a href="javascript:void(0);" onclick="startSound();">播放</a>
<a href="javascript:void(0);" onclick="stopSound();">停止</a><script type="text/javascript">function startSound() {var mp3snd = "plug-in/mp3/smsuccess.wav";var myaudiohtml = "";if (navigator.userAgent.toLowerCase().indexOf("msie") != -1) {myaudiohtml += '<embed src="'+mp3snd+'" type=application/x-mplayer2 width="0" height="0" autostart="1"/>';} else if (navigator.userAgent.toLowerCase().indexOf("firefox") != -1) {myaudiohtml += '<object data="'+mp3snd+'" type="application/x-mplayer2" width="0" height="0">';myaudiohtml += '<param name="filename" value="'+mp3snd+'">';myaudiohtml += '<param name="autostart" value="1">';myaudiohtml += '<param name="playcount" value="infinite">';myaudiohtml += '</object>';} else {myaudiohtml += '<audio src="'+mp3snd+'" autoplay="autoplay" loop="loop">';myaudiohtml += '<object data="'+mp3snd+'" type="application/x-mplayer2" width="0" height="0">';myaudiohtml += '<param name="filename" value="'+mp3snd+'">';myaudiohtml += '<param name="autostart" value="1">';myaudiohtml += '<embed height="2" width="2" src="'+mp3snd+'" pluginspage="http://www.apple.com/quicktime/download/" type="video/quicktime" controller="false" controls="false" autoplay="true" autostart="false" loop="false"><br>';myaudiohtml += '</embed></object>';myaudiohtml += '</audio>';}document.getElementById("audioDiv").innerHTML = myaudiohtml;}function stopSound() {document.getElementById("audioDiv").innerHTML = "";
}</script>