有人可以帮我清除下面代码中的SetInterval。我已经累了window.clearInterval(intervalListener)它不工作。无法清除setInterval
<audio id="audio1" controls="controls" ontimeupdate="init(this.currentTime)"; style="display:block;">
<source src="Audio.mp3" type="audio/mpeg">
<source src="Audio.ogg" type="audio/ogg">
<embed height="50" width="100" src="Audio.mp3"></embed>
</audio>
function init(val)
{
var audio=document.getElementById('audio1');
if(val==2)
{
var a=0;
intervalListener = self.setInterval(function()
{
alert(a);
if(a===8)
{
window.clearInterval(intervalListener);
}
a++;
}, 1000);
}
}
它的工作很好... – 2013-05-14 09:25:41
Chech here http://jsfiddle.net/7XrUq/ – 2013-05-14 09:27:15
我知道它独立调用时效果很好。 – Unknownman 2013-05-14 09:29:44