【问题标题】:YouTube Fancybox not loading the videoYouTube Fancybox 未加载视频
【发布时间】:2012-07-09 05:13:33
【问题描述】:

我已经在网站上设置了一个 PHP 视频浏览器(检查视频 pod),当单击视频缩略图时,应该会弹出一个视频并使用 FancyBox 脚本播放,但视频却无法加载。这是为什么呢?

【问题讨论】:

    标签: javascript jquery youtube fancybox fancybox-2


    【解决方案1】:

    您正在使用带有 fancybox v1.3.x 选项的 fancybox v2.x(它们彼此不兼容。)

    最好的办法是去掉这个脚本:

    <script type="text/javascript">
        $(".videobox").click(function () {
            $.fancybox({
                'padding': 0,
                'autoScale': false,
                'transitionIn': 'none',
                'transitionOut': 'none',
                'title': this.title,
                'width': 680,
                'height': 495,
                'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
                'type': 'swf',
                'swf': {
                    'wmode': 'transparent',
                    'allowfullscreen': 'true'
                }
            });
            return false;
        });
    </script>
    

    试试这个:

    <script type="text/javascript">
        $(document).ready(function () {
            $(".videobox").fancybox({
                width: 680,
                height: 495,
                type: "iframe"
            }); // fancybox
        }); // ready
    </script>
    

    请注意,我们使用的是 type : "iframe",因为您使用的是 youtube embed 模式

    旁注:当您实际需要单个实例(最好是最新版本)以避免意外错误时,您正在加载两个版本的 jQuery(1.7.1 和 1.7.2)。

    【讨论】:

      猜你喜欢
      • 2014-12-20
      • 2012-02-22
      • 2014-04-26
      • 2013-04-04
      • 2014-07-06
      • 1970-01-01
      • 2016-08-10
      • 2014-04-02
      • 2017-03-30
      相关资源
      最近更新 更多