Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Thanked 0 Times in 0 Posts

    Angry Reset YouTube URL inside jQuery lightbox - DRIVING ME NUTS!

    Hi guys,

    I'm trying to create a one-page site that plays YouTube videos inside a lightbox. Everything is working now, except the lightbox keeps playing the same video over and over, even if I click the second, third, fourth, etc. YouTube videos. I think it has something to do with this...

        var video = $('.window iframe[src*="youtube"]');
        if (video.length > 0) {
          var src = video.attr('src');
          video.attr('src', src);
    Here's the JS Fiddle: http://jsfiddle.net/AM9FX/4/

    Probably a really easy fix... Would GREATLY appreciate anyone who can help out here, as this is driving me nuts.

    Thanks in advance!

  2. #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Thanked 257 Times in 253 Posts
    Your fiddle is not working because you did not select jQuery library to use in the left pane.

    For the main issue, do you really need the code you posted? Each link already has its own iframe containing the corresponding YouTube video. Why do you need to set the iframe src on close of the lightbox?

    And why are you using name="lightbox" instead of using class names? Referencing elements using name attribute instead of class name is slower in jQuery.
    Last edited by glenngv; 01-29-2014 at 01:57 AM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts