【问题标题】:Stop youtube video when popup is closed [duplicate]弹出窗口关闭时停止 youtube 视频 [重复]
【发布时间】:2017-10-23 06:47:29
【问题描述】:

我现在是一名程序员并开始了解 css。 我是平面设计专业的学生,​​为我的大项目建立了一个带有 Wordpress 和 Divi 主题的网站。 有一个插件“Bloom”会弹出一个嵌入的 html youtube iframe,但是当它关​​闭时,视频会继续播放。我在论坛上搜索了几天,不太明白如何让它停止。

这是我的弹出窗口的 html。

<html>
 <body>
 <iframe id="ytvideo2" width="640" height="360" src="https://www.youtube.com/embed/IkktPPRahMU?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
 </body>
</html>

还有我在论坛上找到的脚本。

//First get theiframe URL
var url = $('#ytvideo').attr('src');

//Then assign the src to null, this then stops the video been playing
$('#ytvideo').attr('src', '');

// Finally you reasign the URL back to your iframe, so when you hide and load it again you still have the link
$('#ytvideo').attr('src', url);

我什至不知道这是否适合我的脚本以及它应该去哪里。 :( 希望有人能帮助我。 提前致谢。

【问题讨论】:

  • 当弹出窗口关闭时,您需要这样做。检查插件文档,看看它是否提供了任何事件。
  • 添加你用来关闭弹窗的脚本

标签: jquery wordpress iframe youtube


【解决方案1】:

尝试使用 Youtube IFrame API。

请问您是否需要更多帮助:D

https://developers.google.com/youtube/iframe_api_reference?hl=de

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-12
    • 1970-01-01
    • 1970-01-01
    • 2017-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多