Youtube 叠加图像 div - 在下面自动播放



我在这个主页上的YouTube iframe上有一个div覆盖层。

这个想法是你点击一次,然后视频会自动播放,但我就是无法让它打球。 当我设置 YouTube 参数"autoplay=1"时,视频会在图像下方播放,甚至没有点击它。

这是我在下面使用的代码;

<div onclick="thevid=document.getElementById('thevideo');
thevid.style.display='block'; 
this.style.display='none'">
<img style="cursor: pointer;"
src="http://www.belfastdigitalagency.com/wp-content/themes/responsy-v2.5/random_image1.php"
alt="belfast digital marketing agency animated video" />
</div>
<div id="thevideo" style="display: none;">
<iframe width="1280" height="720"
src="http://www.youtube.com/embed/iy_lolGhjPE?rel=0&vq=hd720&color=white&autoplay=0&wmode=transparent&theme=light&showinfo=0&origin=http://www.belfastdigitalagency.com"
frameborder="0" allowscriptaccess="always"
allowfullscreen="true"></iframe>
</div>

知道出了什么问题吗? 提前非常感谢,即使它只是一个指针来检查一些看起来很糟糕的东西!

干杯

菲尔

附言 - 感谢 UnLoCo 的传说,它很快就修复了。这是要更正的最终代码。再次感谢UnLoCo!

<div onclick="thevid=document.getElementById('thevideo');
thevid.style.display='block'; this.style.display='none'; 
document.getElementById('iframe').src = 
document.getElementById('iframe').src.replace('autoplay=0','autoplay=1');">
<img style="cursor: pointer;" src="http://www.belfastdigitalagency.com/wp-content/themes/responsy-v2.5/random_image1.php" alt="belfast digital marketing agency animated video" />
</div>
<div id="thevideo" style="display: none;">
<iframe id="iframe" width="1280" height="720" src="http://www.youtube.com/embed/iy_lolGhjPE?rel=0&vq=hd720&color=white&autoplay=0&wmode=transparent&theme=light&showinfo=0&origin=http://www.belfastdigitalagency.com"
frameborder="0" allowscriptaccess="always" allowfullscreen="true"></iframe>
</div>
单击

时,添加:

document.getElementById('iframe').src = 
document.getElementById('iframe').src.replace('autoplay=0','autoplay=1');

最新更新