1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > JS 声音提示 兼容所有浏览器

JS 声音提示 兼容所有浏览器

时间:2018-12-01 08:07:09

相关推荐

JS 声音提示 兼容所有浏览器

转载自龚清林的博客

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "/DTD/xhtml-mobile10.dtd"> <html><head><title>JS 声音提示</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script></head><body><script language="javascript">playSound();function playSound(){var borswer = window.navigator.userAgent.toLowerCase();if ( borswer.indexOf( "ie" ) >= 0 ){//IE内核浏览器var strEmbed = '<embed name="embedPlay" src="/accessory/ding.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='/accessory/ding.wav' hidden='true'>";if ( $( "body" ).find( "audio" ).length <= 0 )$( "body" ).append( strAudio );var audio = document.getElementById( "audioPlay" );//浏览器支持 audionaudio.play();}}</script></body></html>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。