functionAudioperform () {varUA =navigator.userAgent.toLowerCase (); varaudiopath = "$! {Templetpath}images/ring.wav "; if(Ua.match (/msie ([\d.] +)/) {jQuery (' #alert_sound '). html (' <object classid= ' clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95 "><param name=" AutoStart "value=" 1 "/><param name=" SRC "value=" ' + audiopath + ' "/></object>"); } Else if(Ua.match (/firefox\/([\d.] +)/)) { //jQuery (' #alert_sound '). html (' <embed src= "' + audiopath + '" type= "Audio/wav" hidden= "true" loop= "false" Mastersound></embed> ');JQuery (' #alert_sound '). html (' <audio autoplay= "autoplay" ><source src= "' + audiopath + '" type= "audio/wav"/ ><source src= "$! {templetpath}images/ring.wav "type=" Audio/mpeg "/></audio>"); } Else if(Ua.match (/chrome\/([\d.] +)/) {jQuery (' #alert_sound '). html (' <audio src= "' + audiopath + '" type= "Audio/wav" autoplay= "AutoPlay" hidden= "true" ></ Audio> '); } Else if(Ua.match (/opera. ( [\d.] +)/) {jQuery (' #alert_sound '). html (' <embed src= "' + audiopath + '" hidden= "true" loop= "false" ><noembed><bgsounds src= ' + audiopath + ' ></noembed> '); } Else if(Ua.match (/version\/([\d.] +). *safari/) {jQuery (' #alert_sound '). html (' <audio src= "' + audiopath + '" type= "Audio/wav" autoplay= "AutoPlay" hidden= "true" ></ Audio> '); } Else{jQuery (' #alert_sound '). html (' <embed src= ' + audiopath + ' "type=" Audio/wav "hidden=" true "loop=" false "mastersound>< /embed> '); } }
Web Audio file AutoPlay (compatible with all browsers)