日期:2014-05-16 浏览次数:20381 次
<select name="select" class="reg_tdform_2" id="sel1" onChange="changeSound();"> <option selected="selected" value="<%=basePath%>sound/111.wav">报警声音1</option> <option value="<%=basePath%>sound/222.wav">报警声音2</option> <option value="<%=basePath%>sound/333.wav">报警声音3</option> <option value="<%=basePath%>sound/444.wav">报警声音4</option> <option value="<%=basePath%>sound/555.wav">报警声音5</option> </select> <embed id="alert" src="<%=basePath %>sound/111.wav" loop="false" autostart="false" mastersound hidden="true" type="application/x-mplayer2" ></embed> <img src="<%=basePath %>img/30.gif" width="15px" height="15px" onclick="playSound('play');"/>
<script type="text/javascript"> function changeSound(){ var obj = document.getElementById("sel1"); document.write("原本的路径是:"+document.getElementById("alert").src); selindex = obj.selectedIndex; document.write("选择了第"+selindex+"个选项"); sndsrc = obj.options[selindex].value; document.write("该声音的路径是:"+sndsrc); document.getElementById("alert").src = sndsrc; } </script> <script type="text/javascript"> function playSound(action){ var soundControl = document.getElementById("alert"); if(action=="play"){ soundControl.play(); } } </script>