最近客户要求用Javascript实现视频轮播: 有兴趣的同学可以参开一下 下面写了一个程序实现视频轮播,pc端与移动端均可以实现, 但移动端,存在有一点bug; 复制代码 代码如下: Insert title here 视频轮播11 视频轮播22 <BR>var index=0; <BR>var arr = new Array("71da9e4b6985a7b5951dd62ce7bb020d_7", "71da9e4b691a41961dcd6524593d39ee_7", "71da9e4b69efa71be86d625508ec9feb_7"); <br><br>var container = document.getElementById("container"); <BR>function printPlayer(index){ <BR>//alert(arr.length); <BR>if(index>arr.length-1){ <BR>index=0; <BR>} <BR>//container.removeElement; <BR>container.innerHTML=""; <BR>var vid=arr[index]; <BR>if (navigator.userAgent.match(/iP(od|hone|ad)/i)) { <BR>var video = document.createElement("video"); <BR>video.src = "http://v.polyv.net/uc/video/getMp4?vid="+vid; <BR>video.onended=s2j_onPlayOver; <BR>//video.addEventListener('ended',j2s_onPlayOver, false); <BR>video.autoplay="true"; <BR>video.controls="controls" <BR>container.appendChild(video); <BR>}else{ <br><br>var swf="http://player.polyv.net/player_polyv_20130926a.swf?vid="+vid; <br><br>container.innerHTML = "<OBJECT width='600' height='375' ><PARAM NAME=movie VALUE='"+vid+"'><param name='allowscriptaccess' value='always'>" <BR>+"<param name='allowFullScreen' value='true' />" <BR>+"<EMBED src='"+swf+"' width='600' height='375' TYPE='application/x-shockwave-flash' allowscriptaccess='always' allowFullScreen='true' />" <BR>+""; <BR><!-- container.innerHTML = "<OBJECT>"+swf+"";--> <br><br>} <BR>} <br><br>printPlayer(index); <br><br><BR>/* function j2s_onplayover(){ <BR>index++; <BR>printPlayer(index); <br><br>} */ <br><br>function s2j_onPlayOver() { <BR>alert('ssss'); <BR>index++; <BR>printPlayer(index); <BR>} <BR> 运行效果: