js定時觸發-----新訂單提醒展示效果並提示音效
阿新 • • 發佈:2019-02-04
var playSound = function () {
var borswer = window.navigator.userAgent.toLowerCase();
if ( borswer.indexOf( "ie" ) >= 0 )
{
//IE核心瀏覽器
var strEmbed = '<embed name="embedPlay" src="/admin/images/30.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='/admin/images/30.wav' hidden='true'>";
if($("#audioPlay").length<=0){
$( "body" ).append( strAudio );
}
var audio = document.getElementById( "audioPlay" );
//瀏覽器支援 audio
audio.play();
}
}