今天刚实现的一个例子,根据AJAX动态取得的数据决定播放那条音乐:
function playMiusic(type){
if(type == ""){return;
}
var soundKy="../flash/k.mp3"
var soundSg="../flash/h.mp3"
var soundTs="../flash/t.mp3"
var sound = type == "ky" ? soundKy :
type == "sg" ? soundSg :
type == "ts" ? soundTs : "";
if (navigator.appName=="Microsoft Internet Explorer"){//IE浏览器
document.getElementById("showMusic").innerHTML = '<bgsound src='+'"'+sound+'"'+' loop="infinite">';
} else {//其他浏览器
document.getElementById("showMusic").innerHTML = '<embed src='+'"'+sound+'"'+' hidden="true" autostart="true" loop="true">';
}
}