WEB开发网
开发学院网页设计JavaScript js实现多浏览器下循环播放背景音乐 阅读

js实现多浏览器下循环播放背景音乐

 2012-11-08 14:13:06 来源:WEB开发网   
核心提示: var mp3snd = "./xxx.mp3";var bkcolor = "000000";if ( navigator.userAgent.toLowerCase().indexOf( "msie" ) != -1 ) {document.write(

 var mp3snd = "./xxx.mp3";
var bkcolor = "000000";

if ( navigator.userAgent.toLowerCase().indexOf( "msie" ) != -1 ) {
document.write('<bgsound src="'+mp3snd+'" loop="-1">');
}
else if ( navigator.userAgent.toLowerCase().indexOf( "firefox" ) != -1 ) {
document.write('<object data="'+mp3snd+'" type="application/x-mplayer2" width="0" height="0">');
document.write('<param name="filename" value="'+mp3snd+'">');
document.write('<param name="autostart" value="1">');
document.write('<param name="playcount" value="infinite">');
document.write('</object>');
}
else {
document.write('<audio src="'+mp3snd+'" autoplay="autoplay" loop="loop">');
document.write('<object data="'+mp3snd+'" type="application/x-mplayer2" width="0" height="0">');
document.write('<param name="filename" value="'+mp3snd+'">');
document.write('<param name="autostart" value="1">');
document.write('<embed height="2" width="2" src="'+mp3snd+'" pluginspage="http://www.apple.com/quicktime/download/" type="video/quicktime" controller="false" controls="false" autoplay="true" autostart="true" loop="true" bgcolor="#'+bkcolor+'"><br>');
document.write('</embed></object>');
document.write('</audio>');
}

Tags:js 实现 浏览器

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接