<body>
<video id=”myvideo” width=”50%” controls=”controls” poster=”img/cars.png”>
<source src=”mooc%2FsJRdJ8FAQy.mp4″ type=”video/mp4″>
</video>
<script type=”text/javascript”>
var video = document.getElementById(‘myvideo’);
var currentTime = localStorage.getItem(“currentTime”);
console.log(currentTime);
video.addEventListener(“loadedmetadata”,function(){
this.currentTime = currentTime;
});
video.addEventListener(“timeupdate”,function(){
var currentTime = Math.floor(video.currentTime);
localStorage.setItem(“currentTime”,currentTime);
console.log(localStorage.getItem(“currentTime”));
});
</script>
</body>
————————————————
版权声明:本文为CSDN博主「时不我待、」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/WXN069/article/details/100768719
var weekArray = [‘周一‘、‘周二‘、‘周三‘、‘周四‘、‘周五‘]
存:localStorage.setItem(‘weekDay’,JSON.stringify(weekArray));
取: weekArray = JSON.parse(localStorage.getItem(‘weekDay’));