start/play embedded (iframe) youtube-video on click of an image

前端 未结 7 1285
一整个雨季
一整个雨季 2020-12-07 22:20

I\'m trying to start playing an embedded youtube video by clicking an image. The idea is to have an image on top of a video, and when the image is clicked it fades out and s

相关标签:
7条回答
  • 2020-12-07 22:59

    This should work perfect just copy this div code

    <div onclick="thevid=document.getElementById('thevideo'); thevid.style.display='block'; this.style.display='none'">
    <img style="cursor: pointer;" alt="" src="http://oi59.tinypic.com/33trpyo.jpg" />
    </div>
    <div id="thevideo" style="display: none;">
    <embed width="631" height="466" type="application/x-shockwave-flash" src="https://www.youtube.com/v/26EpwxkU5js?version=3&amp;hl=en_US&amp;autoplay=1" allowFullScreen="true" allowscriptaccess="always" allowfullscreen="true" />
    </div>
    
    0 讨论(0)
提交回复
热议问题