在Firefox中隐藏元素时,Youtube的播放停止

时间:2012-02-11 16:34:54

标签: javascript jquery html youtube

我正在尝试隐藏Youtube视频,同时播放。在Chrome中,它运行良好但在Firefox中,隐藏时播放停止。

这是我点击#hide

的代码
$('#hide').click(function(){
            $('.flash-wrapper').toggleClass("hidden");
            $('#footer').fadeToggle();
            var hideText = $('#hide').text();
            if(hideText == "Hide everything") {
                $('#hide').text('Show everything');
            } else {
                $('#hide').text('Hide everything');
            }
        });

隐藏课程

.hidden {
        position: absolute;
        left: -10000px;

    }

一个.flash-wrapper

的示例
<div class="flash-wrapper Jj6yXxVc21Y">
<div id="Jj6yXxVc21Y">
  You need Flash player 8+ and JavaScript enabled to view this video.
</div>
    <script type="text/javascript">

        var params = { allowScriptAccess: "always" };
        var atts = { id: "Jj6yXxVc21Y" };
        swfobject.embedSWF("http://www.youtube.com/v/Jj6yXxVc21Y&enablejsapi=1&playerapiid=ytplayer", "Jj6yXxVc21Y", "250", "25", "8", null, null, params, atts);

    </script>
</div>

flash-wrapper类

.flash-wrapper {
    float: left;
    margin-left: 5px;
}

1 个答案:

答案 0 :(得分:1)

我将.hidden更改为以下代码,现在播放不会停止

.hidden {
    margin-top: -1000px;
}