开发者

Lightbox will not play video after first time

开发者 https://www.devze.com 2023-04-03 04:54 出处:网络
I have an embedded YouTube video on my site that pl开发者_JAVA技巧ays in a lightbox. When an user clicks the link the video plays fine the first time. If the user closes the lightbox then tries to cli

I have an embedded YouTube video on my site that pl开发者_JAVA技巧ays in a lightbox. When an user clicks the link the video plays fine the first time. If the user closes the lightbox then tries to click the link for the video again the lightbox loads but no video plays. It shows a blank screen.

Any ideas what is going on?

Here is the code:

Link:

<a id="playvid" href="#video"><img src="/image" width="70" alt="Extra 1" /></a

DIV with Video:

div style="display:none"><div id="video" style="width:420; height:345;">
<iframe width="420" height="345" src="http://www.youtube.com/embed/..."
frameborder="0" allowfullscreen></iframe>
</div>
</div>

Script:

<script type="text/javascript">
    var $j = jQuery.noConflict();
    $j(document).ready(function() {
$j("a.fancybox").fancybox();
$j("a#playvid").fancybox();
});
</script>

I am using Fancybox 1.3.4


All right, than problem is pretty simple. Because of what fancybox does internally when you close the fancybox (it clears "src" attribute for any iframes it finds in the contents it displays). The second time you want to see the video the src attribute has been cleared so you don't see anything.

Solution is to either hack into the fancybox src and comment out the line responsible for clearing the "src" attribute of an iframes) or ... hmm I don't know what else, I would have to dig in deeper.

0

精彩评论

暂无评论...
验证码 换一张
取 消