1

I've been banging my head on trying to get my embedded youtube playlist to stop (preferrably pause) when the user opens a new browser window via a link from within the webpage. This link goes to another page which also automatically starts a video (nobody wants two videos playing at once). This is the bare bones code I have thus far. Thanks for the help.

<iframe width="452" height="278" src="//www.youtube.com/embed/videoseries?list=PL3NaSh-osYfmAc4IUijQN1aJGDehZepVQ&autoplay=1?enablejsapi=1" frameborder="0" allowfullscreen></iframe>
Chris Stratton
  • 39,853
  • 6
  • 84
  • 117

1 Answers1

0

You can catch the link onClick, call pause to the Youtube control and continue with opening the link. More like this:

Remove the href from your link, and set a #mark. Set an id (let's suppose is myLink). Catch the click on the link:

 $("#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. 

   });
celerno
  • 1,367
  • 11
  • 30
  • The problem with this is, `window.open` is treated like a popup window, and may even be initially blocked. – levi Mar 03 '14 at 18:31
  • 1
    so long as you are not calling `e.preventDefault()`, the link should continue opening as expected, so `window.open` may not even be necessary. – levi Mar 03 '14 at 18:34
  • right about both comments. Edited and added your feedback, hope you don't mind. – celerno Mar 03 '14 at 19:05
  • Sorry guys I'm not a programmer by any means. I'll probably have to be given the entire code. I'm getting pretty lost in trying to put things together on my end. – user3376013 Mar 03 '14 at 19:13
  • Also, I probably should have added, that the link is not in text form, it's actually a picture which opens into a new link in another browser window. – user3376013 Mar 03 '14 at 20:32