最近客戶要求用Javascript實現視訊輪播: 有興趣的同學可以參開一下下面寫了一個程式實現視訊輪播,pc端與行動端均可以實現, 但移動端,存在有一點bug; 複製代碼 代碼如下: Insert title here 視訊輪播11 視訊輪播22 <BR>var index=0; <BR>var arr = new Array("71da9e4b6985a7b5951dd62770" 71da9e4b691a41961dcd6524593d39ee_7", "71da9e4b69efa71be86d625508ec9feb_7"); <br><br>var container = document. 🎜>//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 VAL' ><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><br>function s2j_onPlayOver() { <.' '); <BR>index ; <BR>printPlayer(index); <BR>} <BR> 運作效果: