小编016*_*Jon的帖子

隐藏iframe时如何暂停YouTube播放器?

我有一个隐藏的div包含一个YouTube视频<iframe>.当用户点击链接时,该div变为可见,然后用户应该能够播放视频.

当用户关闭面板时,视频应停止播放.我怎样才能做到这一点?

码:

<!-- link to open popupVid -->
<p><a href="javascript:;" onClick="document.getElementById('popupVid').style.display='';">Click here</a> to see my presenting showreel, to give you an idea of my style - usually described as authoritative, affable and and engaging.</p>

<!-- popup and contents -->
<div id="popupVid" style="position:absolute;left:0px;top:87px;width:500px;background-color:#D05F27;height:auto;display:none;z-index:200;">

  <iframe width="500" height="315" src="http://www.youtube.com/embed/T39hYJAwR40" frameborder="0" allowfullscreen></iframe>

  <br /><br /> 
  <a href="javascript:;" onClick="document.getElementById('popupVid').style.display='none';">
  close
  </a>
</div><!--end of popupVid -->
Run Code Online (Sandbox Code Playgroud)

javascript youtube-api youtube-javascript-api

84
推荐指数
7
解决办法
12万
查看次数