Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    3
    Thanks
    0
    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...

    Code:
        var video = $('.window iframe[src*="youtube"]');
    
        if (video.length > 0) {
          var src = video.attr('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
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 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 12:57 AM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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