Twitter Bootstrap Modal 停止 Youtube 视频

2023-11-29

我对 javascript 很陌生,并尝试使用 Twitter bootstrap 来快速启动并运行一个美观的网站。我知道这与 jquery 有关,但我不确定当我按下关闭按钮或关闭图标时如何停止我的视频。

有人可以解释一下如何让我的视频停止播放,因为即使我关闭窗口,我仍然可以在后台听到它。

<!-- Button to trigger modal -->
    <a href="#myModal" role="button" class="btn" data-toggle="modal"><img src="img/play.png"></a>

<!-- Modal -->
  <div id="myModal" class="modal hide fade" tabindex="-1" role=labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria>×</button>
      <h3 id="myModalLabel">I am the header</h3>
    </div>
    <div class="modal-body">
      <p><iframe width="100%" height="315" src="http:com/embed/662KGcqjT5Q" frameborder="0" allowfullscreen></iframe></p>
    </div>
    <div class="modal-footer">
      <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    </div>
  </div>

我知道我晚了 2 年多,但从那时起,一些事情发生了变化,使用 B3 开箱即用地执行此操作的新方法是:

$("#myModal").on('hidden.bs.modal', function (e) {
    $("#myModal iframe").attr("src", $("#myModal iframe").attr("src"));
});

享受 Bootstrap 带来的乐趣!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Twitter Bootstrap Modal 停止 Youtube 视频 的相关文章

随机推荐