var soundBgm=document.getElementById("music"); //判断本地是否有存储过音频播放时间 if(sessionStorage.bgmTime==null){ //若没有时,从头自动播放 soundBgm.currentTime=0; }else{ //若有存储的则,取出本地存储的音频播放的暂停时间 var curTime=window.sessionStorage.getItem("bgmTime"); sessionStorage.bgmPlay=soundBgm.bgmPlay; //从暂停时间开始接着播放 soundBgm.currentTime+=curTime; } //页面跳转时将本页面音频最后截至时间存储下来 function fun(){ soundBgm.pause(); sessionStorage.bgmPlay=soundBgm.bgmPlay; sessionStorage.bgmTime=soundBgm.bgmPlay?soundBgm.currentTime+soundBgm.context.currentTime-soundBgm.startTime:soundBgm.currentTime; location.href='02.html'; }
|