2012-08-16 23 views
2

我在此homepage上的YouTube iframe之上覆盖了div覆盖。Youtube覆盖图片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> 

任何想法发生了什么问题?事先很感激,即使它只是一个指针,检查出看起来不好的东西!

干杯,

菲尔

P.S - 由于这是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> 

回答

6

,添加:

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

谢谢UnLoCo,你可以请把在我通俗地说?我是新来的游戏! – 2012-08-16 22:03:23

+0

嗨,这段代码替换自动播放= 1; iframe src属性上的autoplay = 0;这意味着它会使iframe自动重新加载和播放。 – UnLoCo 2012-08-16 22:04:55

+0

这是你的意思? '