Fancybox YouTube视频无法在Localhost上工作

Fancybox YouTube Video not working on Localhost

本文关键字:Localhost 工作 YouTube 视频 Fancybox      更新时间:2023-09-26

我在本地主机上运行Fancybox的YouTube视频实现时遇到问题。当我加载页面时,我得到这个错误:

Unsafe JavaScript attempt to access frame with URL http://sites:8888/clients/project_name/v1/products/index from frame with URL http://www.youtube.com/embed/RtXSVGsQ8N0. Domains, protocols and ports must match.

很明显,在将实现推送到实时服务器之前,我想确保它正常工作。

提前谢谢。

似乎您正在尝试进行跨域ajax调用。你的浏览器是什么?

要澄清ToyDaVirus,请确保在参数中将类型指定为iframe

'type' : 'iframe'


$('#selector').click(function() {
        $.fancybox({
        'padding'           : 10,
        'autoScale'         : false,
        'transitionIn'      : 'elastic',
        'centerOnScroll'    : true,
        'overlayColor'      : '#000',
        'transitionOut'     : 'none',
        'title'             : this.title,
        'width'             : 680,
        'height'            : 495,
        'href'              : this.href.replace(new RegExp("watch''?v=", "i"), 'v/'),
        'type'              : 'iframe',
        'swf'               : {
            'wmode'             : 'transparent',
            'allowfullscreen'   : 'true'
        }
        });
        return false;
});