add random youtube video to your web or blogger

watch on youtube

first of all, you must write javascript code like this :

function randomRange(l,h){  var range = (h-l);  var random = Math.floor(Math.random()*range);  if (random === 0){random+=1;}  return l+random;}
function get_random_yid(){        var ids = document.getElementsByClassName("youtube-id");    var idx = randomRange(ids.length,0);    return ids[idx].getAttribute("id");}
function frx_ytb_show(autoPlay){        var videos = document.getElementsByClassName("youtube-frame");      for (var i=0; i<videos.length; i++) {          var youtube = videos[i];          var yid = get_random_yid();        youtube.setAttribute("id", yid);["position"]="relative";          if(autoPlay)           youtube.setAttribute("src",           "" +            + "?autoplay=1&autohide=1&border=0&wmode=opaque&enablejsapi=1");            else            youtube.setAttribute("src",                "" +                 + "?autohide=1&border=0&wmode=opaque");     }}
copy and save to file, or you can download here : 

go to your blogger dashboard or you site html, then add the script:
i use blogger for this example.

1. edit html

2. add script

3. Search </body> 

4. call the script before </body>
set parameter 1 will make script to play youtube video automatically.

5. Add your video-id list (multiple video id)
at this example i use a gadget to put video list.

i also put youtube frame here ( you may put at any places on your web/blogger) 

you can put another youtube frame (viewer) (multiple youtube frame)

Post a Comment