我要做一个主要靠手机来显示的内嵌Video的HTML。其中,包括一个功能,在播放到一部分后关闭浏览器,然后重开浏览器,按继续按钮可以接着上次结束的地方继续播放。所以,我用COOKIE记录了上次关闭浏览器时 Video.currentTime的值,然后在
继续播放按钮的监听中再赋值,然后达到继续播放的效果。这个在电脑浏览器中,没有出现任何问题,但是,在手机浏览器(both iphone and android)里, Video.currentTime= resumingTime 这句就不行,有高手指教一下吗?附上HTML和COOKIE.JS。
<!DOCTYPE html>
<html><head>
<script type="text/javascript" src="js/cookie.js"></script>
<script type="text/javascript">
var video = null;
var resBtn = null;
var resumingTime = null;
//resize function called whenever resize event occurs
function resizeEle(){

video = document.getElementsByTagName("video")[0];
resBtn = document.getElementById("resume");
if(video){
video.width = window.innerWidth*7/8;
}

if(resBtn){
resBtn.width = window.innerWidth/5;
}
}

//called whenever Button Resume is clicked
function resClick(){

resumingTime = readCookie("resumingTime");
if(resumingTime){
alert(resumingTime);
video.currentTime = resumingTime;
video.play();




}
else{
video.play();
video.currentTime = 30*60 + 0.1;
}

}

//called when page tab is closed, to record the currentTime of video
function timeRecording(){

resumingTime = video.currentTime;
alert(resumingTime);
writeCookie("resumingTime", resumingTime, 14);

}

</script>
<style>
video{
margin: 10px 10px 10px 10px;
}
#resume{
margin: 2px 2px 2px 2px;
}

</style>


</head><body onload="resizeEle()" onresize="resizeEle()" onunload="timeRecording()">

<video  controls>
<source src="video/video02.mp4" type="video/mp4" />
<source src="video/video02.ogg" type="video/ogg" />
<source src="video/video02.webm" type="video/webm" />
Your browser does not support the video tag.
</video>
<br/>
<input id="resume" type="image" src="img/Resume.jpg" onclick="resClick()"/>

</body>
</html>function writeCookie(name, value, days) {
// By default, there is no expiration so the cookie is temporary
var expires = "";
// Specifying a number of days makes the cookie persistent
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toGMTString();
}
// Set the cookie to the name, value, and expiration date
document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
// Find the specified cookie and return its value
var searchName = name + "=";
var cookies = document.cookie.split(';');
for(var i=0; i < cookies.length; i++) {
var c = cookies[i];
while (c.charAt(0) == ' ')
c = c.substring(1, c.length);
if (c.indexOf(searchName) == 0)
return c.substring(searchName.length, c.length);
}
return null;
}
function eraseCookie(name) {
// Erase the specified cookie
writeCookie(name, "", -1);
}