www.webdeveloper.com
Results 1 to 4 of 4

Thread: loading next video onClick in iframe

  1. #1
    Join Date
    Mar 2013
    Posts
    6

    loading next video onClick in iframe

    Hi,

    I am a total newbie to coding so my effort below isn't good.

    Basically I have the iframe playing a video on loop (when the src=a link). I need to change it so when I click the next button below the video, the next video plays. Can anyone help?

    <div class="video-div">
    <iframe src="http://vine.co/v/ video_url " width="380" height="380" frameborder="0"></iframe>

    onClick= loadnext

    var video_url= [bpDrlqijZat , bpDJabIh9mV , bpDbHPhK703 , bpdphbvgmUI ];

    Thanks
    Matt

  2. #2
    Join Date
    Jan 2004
    Location
    chertsey, a small town s.w. of london, england.
    Posts
    1,456
    Hi there matt_saber,

    and a warm welcome to these forums.

    Does this example help...
    Code:
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    
    <title>video links</title>
    
    <style type="text/css">
    body {
        background-color:#f0f0f0;
     }
    #video-div {
        position:relative;
        width:338px;
        min-height:438px;
        padding:10px;
        border:1px solid #999;
        margin:20px auto;
        background-color:#fff;
        box-shadow:8px 8px 8px rgba(0,0,0,0.6),inset 0 0 8px rgba(0,0,0,0.4);
     }
    .hide {
        display:none;
     }
    #video {
        display:block;
        width:338px;
        height:398px;
     }
    #button {
        position:absolute;
        bottom:10px;
        left:120px;
        width:100px;
        cursor:pointer;
     }
    </style>
    
    <script type="text/javascript">
    (function() {
       'use strict';
    
       var url='http://vine.co/v/';
       var ary=['bpDrlqijZat','bpDJabIh9mV','bpDbHPhK703','bpdphbvgmUI'];
    
       var c=0;
       var obj,obj1;
    
    function init(){
       obj1=document.getElementById('video-div');
       obj1.className='';
    
       makeObject();
    
       var but=document.createElement('button');
           but.setAttribute('id','button');
       var txt=document.createTextNode('next video');
           but.appendChild(txt);
           obj1.appendChild(but);
    
    document.getElementById('button').onclick=function(){
       obj1.removeChild(obj);
    if(c==ary.length-1) {
       c=-1;
     }
       c++;
       makeObject();
      }
     }
    
    function makeObject(){
          obj=document.createElement('object');
          obj.setAttribute('id','video');
          obj.setAttribute('type','text/html');
          obj.setAttribute('data',url+ary[c]);
          obj1.appendChild(obj);
     }
    
       window.addEventListener?
       window.addEventListener('load',init,false):
       window.attachEvent('onload',init);
    
    })();
    </script>
    
    </head>
    <body>
    
    <div id="video-div" class="hide"></div>
    
    </body>
    </html>
    coothead

  3. #3
    Join Date
    Mar 2013
    Posts
    6
    With a few additions this worked well. I added /card at the end of the Vine domain to achieve a cleaner look on the page. Thanks

  4. #4
    Join Date
    Jan 2004
    Location
    chertsey, a small town s.w. of london, england.
    Posts
    1,456
    No problem, you're very welcome.



    coothead

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles