打开新的浏览器窗口时暂停YouTube视频



我一直在努力让我的嵌入式 youtube 播放列表停止(最好是暂停),当用户通过网页内的链接打开新的浏览器窗口时。此链接转到另一个页面,该页面也会自动启动视频(没有人希望同时播放两个视频)。这是我迄今为止拥有的基本代码。感谢您的帮助。

<iframe width="452" height="278" src="//www.youtube.com/embed/videoseries?list=PL3NaSh-osYfmAc4IUijQN1aJGDehZepVQ&autoplay=1?enablejsapi=1" frameborder="0" allowfullscreen></iframe>

您可以在单击时捕获链接,将暂停调用到 Youtube 控件并继续打开链接。更多像这样:

从链接中删除 href,并设置 #mark。设置一个id(假设是myLink)。点击链接:

 $("#myLink").click(function(e) {
   //call pause on your Youtube control. See this response: http://stackoverflow.com/a/12522499/335905 
   // as long as you are not calling e.preventDefault(), the link should continue opening as expected. 
   });

最新更新