var player=null;
function play(AudioU,AudioUU,id)
{
var pdiv=document.getElementById("playdiv");
if(pdiv.style["display"]=="none")
{
pdiv.style["display"]="block";
}
if(player!=null)
{
pdiv.removeChild(player);
player=null;
}
player=document.createElement("embed");
player.src="";
player.setAttribute("type","application/x-mplayer2");
player.setAttribute("width","100%");
player.setAttribute("height","45px");
player.setAttribute("loop",-1);
player.setAttribute("id","player1");
player.setAttribute("src","<%=sppath%>/audio/"+"unit"+AudioU+"/"+"unit"+AudioUU+"/"+id+".wma");//路径为绝对路径
player.setAttribute("autostart","1");
pdiv.appendChild(player);
}
<div id="playdiv" style="width:100%;height:50px; overflow:hidden; "></div>
调用: onClick="play(1,1,1);"