Click on image (splashscreen) to play embedded Youtube Movie

前端 未结 4 641
予麋鹿
予麋鹿 2021-02-04 13:41

I Was wondering how to make something as followed:

I want to have an image that displays a splash image, clicking on that image it will play a youtube Movie in the same

4条回答
  •  礼貌的吻别
    2021-02-04 13:54

    I found this through Google and needed to do this not with an embed, but with the new (relatively) iframe style that YouTube has for HTML5. I found the solution to be lacking in that it did not differentiate text nodes from elements (firefox's nextSibling and IE's nextSibling). Also, when the video is clicked, the user needed to click twice, once on the image, then once on the YouTube player. This is fixed with the autoplay flag in the YouTube URL. The final behavior is correct in Chrome, Firefox, IE 7+, etc.

    Here is my final solution:

    
    
    splash

提交回复
热议问题