<html>
<head>
<title>Greeting - Basic</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=javascript>
var i=0;
function plays(){
if(i==0){document.a.play();i++;}
else { document.a.pause();i--;}
}
</script>
</head>
<body>
<embed name=a src="c:/a.mp3" loop=false autostart=false mastersound hidden=true width=0 height=0></embed>
<a href="#" onClick="plays()"> 播放/暂停</a> <br><br>
</body> </html> 上面程序的功能是点击"播放/暂停"按钮会听到一段声音,但我有n个"播放/暂停"按钮,可否把plays方法写成一个通法?
<head>
<title>Greeting - Basic</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=javascript>
var i=0;
function plays(){
if(i==0){document.a.play();i++;}
else { document.a.pause();i--;}
}
</script>
</head>
<body>
<embed name=a src="c:/a.mp3" loop=false autostart=false mastersound hidden=true width=0 height=0></embed>
<a href="#" onClick="plays()"> 播放/暂停</a> <br><br>
</body> </html> 上面程序的功能是点击"播放/暂停"按钮会听到一段声音,但我有n个"播放/暂停"按钮,可否把plays方法写成一个通法?
function plays()
{
if(i==0)
{
document.a.play();
documnet.b.play();
document.x.play();
i++;
}
else
{
全停止,照着上面抄一遍
}
}
似乎就行
<head>
<title></title>
<script language=javascript>
function play(obj,isPause){
var emb=document.getElementById(obj)
if(emb.isPlay==true||isPause==true){
emb.isPlay=false;
emb.pause();
}else {
emb.isPlay=true;
emb.play();
}
}
function pauseAll(){
play('p1',true);
play('p2',true);
play('p2',true);
}
</script>
</head>
<body>
<embed name=p1 src= "E:\music\soft\NewMailMsg.mp3" loop=false autostart=false mastersound hidden=true width=0 height=0> </embed>
<embed name=p2 src= "E:\TDDOWNLOAD\47587.mp3" loop=false autostart=false mastersound hidden=true width=0 height=0> </embed>
<embed name=p3 src= "E:\TDDOWNLOAD\310984657.mp3" loop=false autostart=false mastersound hidden=true width=0 height=0> </embed>
<a href= "# " onClick="pauseAll();play('p1')"> 播放/暂停 </a>
<a href= "# " onClick="pauseAll();play('p2')"> 播放/暂停 </a>
<a href= "# " onClick="pauseAll();play('p3')"> 播放/暂停 </a>
</body>
</html>