在用js定时器控制视频时,
html部分:
<video id="video_1"> <source id="source_1" src="video.mp4"/> </video>
js部分:
//定义一个定时器 var time = null, //定义一个变量,通过id找到video标签 video_change = null, source_change = null; window.onload = function (){ time = setInterval("change()",5000); } function change(){ video_change = document.getElementById("video_1"); source_change = document.getElementById("source_1"); video_change.load(); source_change.src = "video.mp4"; }