點評:在html 5中的audio標籤中,只有暫停按鈕,但沒有停止按鈕,其實為其增加也不麻煩,接下來介紹實現方法,有需要的朋友可以參考下
在html 5中的audio標籤中,只有暫停按鈕,但沒有停止按鈕,其實為其增加也不麻煩,方法如下:HTMLAudioElement.prototype.stop = function()
{
this.pause();
this.currentTime = 0.0;
}
其實很簡單,就是先暫停,然後時間歸0;
調用方法:
var aud = new Audio();
aud.src = '特殊他.ogg';
aud.play();
aud.stop();
上面代碼可以在chrome,opera下跑,但firefox 17不行