Results 1 to 8 of 8

Thread: video pop-up code?

  1. #1
    Join Date
    Feb 2005
    Posts
    71
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default video pop-up code?

    I am embedding a youtube video into a website. I want the embedded image/video to be small but for viewers to have the option to click on the image/video (or below) and watch the video in a larger size as a pop-up.

    Can anyone tell me where I might find a code to enable this please?

    Thanks in advance.

  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Something like the following(?):
    Head:
    Code:
    <script type="text/javascript">
    function big_yt(yt_container,url)
    {
    document.getElementById(yt_container).innerHTML='<div style="position: absolute; left: 50px; top: 100px; right: 50px; bottom: 80px"><div style="position: relative; float: right; cursor: pointer" onclick="document.getElementById(\''+yt_container+'\').innerHTML=\'\'">CLOSE<\/div><br><iframe src="'+url+'" style="position: absolute; width: 100%; height: 100%" frameborder="0"><\/iframe><\/div>'
    }
    </script>
    Body:
    Code:
    <div style="text-align: center">
    <a onclick="big_yt('video_container','http://www.youtube.com/v/TjLCJKoot4U?version=3&amp;autoplay=1')"><img src="http://img.youtube.com/vi/TjLCJKoot4U/1.jpg" height="70" width="90"  title="Cougar Scene" alt="" style="cursor: pointer"></a> 
    <a onclick="big_yt('video_container','http://www.youtube.com/v/1vrKeslu2KM?version=3&amp;autoplay=1')"><img src="http://img.youtube.com/vi/1vrKeslu2KM/1.jpg" height="70" width="90"  title="Neanderthal" alt="" style="cursor: pointer"></a> 
    <a onclick="big_yt('video_container','http://www.youtube.com/v/Tek_i2d7bP4?version=3&amp;autoplay=1')"><img src="http://img.youtube.com/vi/Tek_i2d7bP4/1.jpg" height="70" width="90"  title="Cro-Magnon" alt="" style="cursor: pointer"></a> 
    </div>
    <div id="video_container"></div>
    Arie Molendijk.

  3. The Following User Says Thank You to molendijk For This Useful Post:

    robertsaunders (02-18-2012)

  4. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    There are also various 'box' type scripts that can do that sort of thing:

    http://fancybox.net/

    and:

    http://www.no-margin-for-errors.com/.../#!prettyPhoto

    are two that can handle Flash video in various ways.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. The Following User Says Thank You to jscheuer1 For This Useful Post:

    robertsaunders (02-18-2012)

  6. #4
    Join Date
    Feb 2005
    Posts
    71
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Thank you for both of your replies. I'm not going to be updating the site for a week or so but I've had a look the posts and they look like exactly what I was looking for.

  7. #5
    Join Date
    Jun 2015
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to play the video automatically ???

    Quote Originally Posted by molendijk View Post
    Something like the following(?):
    Head:
    Code:
    <script type="text/javascript">
    function big_yt(yt_container,url)
    {
    document.getElementById(yt_container).innerHTML='<div style="position: absolute; left: 50px; top: 100px; right: 50px; bottom: 80px"><div style="position: relative; float: right; cursor: pointer" onclick="document.getElementById(\''+yt_container+'\').innerHTML=\'\'">CLOSE<\/div><br><iframe src="'+url+'" style="position: absolute; width: 100%; height: 100%" frameborder="0"><\/iframe><\/div>'
    }
    </script>
    Body:
    Code:
    <div style="text-align: center">
    <a onclick="big_yt('video_container','http://www.youtube.com/v/TjLCJKoot4U?version=3&amp;autoplay=1')"><img src="http://img.youtube.com/vi/TjLCJKoot4U/1.jpg" height="70" width="90"  title="Cougar Scene" alt="" style="cursor: pointer"></a> 
    <a onclick="big_yt('video_container','http://www.youtube.com/v/1vrKeslu2KM?version=3&amp;autoplay=1')"><img src="http://img.youtube.com/vi/1vrKeslu2KM/1.jpg" height="70" width="90"  title="Neanderthal" alt="" style="cursor: pointer"></a> 
    <a onclick="big_yt('video_container','http://www.youtube.com/v/Tek_i2d7bP4?version=3&amp;autoplay=1')"><img src="http://img.youtube.com/vi/Tek_i2d7bP4/1.jpg" height="70" width="90"  title="Cro-Magnon" alt="" style="cursor: pointer"></a> 
    </div>
    <div id="video_container"></div>
    Arie Molendijk.
    Thanks for this code. Is it possible to play the video automatically (No need to click ) ???

  8. #6
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Isn't that what the autoplay=1 parameter in the URL is already doing?
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  9. #7
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    I had a look here and although the previous code works OK on destktop, it doesn't work on iOS - probably because the YouTube API has changed since 2012 when this solution was posted. Updated API docs here: https://developers.google.com/youtub...etting-started

    Try this updated alternative http://fofwebdesign.co.uk/template/_...tube-popup.htm (responsive and works on iOS)
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  10. #8
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    A few remarks.
    Yes, the YouTube API has changed since 2012 when my solution was posted.
    Berverleyh's solution works OK.
    The person wants the video to autoplay on page load, so we could do this (adapted to the new API, I guess, but I'm not sure as I dont't have a small device here; most of the time I'm disconnected in this isolated region of Europe, where (holiday-)life is so simple and beautiful):
    HEAD:
    Code:
    <script type="text/javascript">
    function big_yt(url)
    {
    var ifr_height=document.getElementById('video_container').clientHeight-20;
    document.getElementById('video_container').innerHTML='<div style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; font-family: verdana; font-size: 13px; color: white; cursor: pointer"><div style="position: relative; float: right; height:20px" onclick="document.getElementById(\'video_container\').innerHTML=\'\'">CLOSE<\/div><br><iframe src="'+url+'" style="position: absolute; width: 100%; z-index: 1; height:'+ifr_height+'px" frameborder="0"><\/iframe><\/div>'
    }
    window.onload=function() {big_yt('http://www.youtube.com/embed/TjLCJKoot4U?autoplay=1&amp;rel=0')}
    </script>
    BODY:
    Code:
    <div style="text-align: center">
    
    <a onclick="big_yt('http://www.youtube.com/embed/TjLCJKoot4U?autoplay=1&amp;rel=0')"><img src="http://img.youtube.com/vi/TjLCJKoot4U/1.jpg" height="70" width="90"  title="Cougar Scene" alt="" style="cursor: pointer"></a> 
    
    <a onclick="big_yt('http://www.youtube.com/embed/1yUfSZTXh9g?autoplay=1&amp;rel=0')"><img src="http://img.youtube.com/vi/1yUfSZTXh9g/1.jpg" height="70" width="90"  title="Ezinge, my village" alt="" style="cursor: pointer"></a> 
    
    <a onclick="big_yt('http://www.youtube.com/embed/F1HDmXMl8GM?autoplay=1&amp;rel=0')"><img src="http://img.youtube.com/vi/F1HDmXMl8GM/1.jpg" height="70" width="90"  title="We have plenty of water" alt="" style="cursor: pointer"></a> 
    
    </div>
    
    <div id="video_container" style="position: absolute; left: 50px; top: 100px; right: 50px; bottom: 80px; background: black"></div>
    
    <div style="position: absolute; left: 50%; top: 50%; margin-left: -60px; color: white; font-family: verdana; font-size: 13px">Select a video on top</div>
    You may also be interested in (the source of) this test page.
    Last edited by molendijk; 06-02-2015 at 03:25 PM.

Bookmarks

Posting Permissions

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