Phi*_*nes 2 html youtube iframe overlay onclick
我在这个主页上的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>
Run Code Online (Sandbox Code Playgroud)
有什么想法会出错吗?事先得到很多赞赏,即使它只是一个指出看看看起来很糟糕的东西的指针!
干杯,
菲尔
PS - 感谢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>
Run Code Online (Sandbox Code Playgroud)
点击,添加:
document.getElementById('iframe').src =
document.getElementById('iframe').src.replace('autoplay=0','autoplay=1');
Run Code Online (Sandbox Code Playgroud)