Fancybox没有在IE中加载,忽略了返回false

时间:2010-12-07 15:09:05

标签: jquery internet-explorer fancybox

我正在尝试启用fancybox,以便当用户点击缩略图时,视频会在Fancybox窗口/叠加层中打开。我有以下JavaScript + html,除了Internet Explorer之外,所有浏览器都能正常运行。在Internet Explorer中,它只是转到包含视频的youtube页面。有谁熟悉这个问题并知道解决方案吗?

$('body').delegate('.video .thumbholder a','click', function(){
    $.fancybox({
            'padding'       : 0,
            'autoScale'     : false,
            'transitionIn'  : 'none',
            'transitionOut' : 'none',
            'title'         : $(this).title,
            'width'         : 680,
            'height'        : 495,
            'href'          : $(this).attr('href').replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type'          : 'swf',
            'swf'           : {
                 'wmode'        : 'transparent',
                'allowfullscreen'   : 'true'
            }
        });
    return false;
});

2 个答案:

答案 0 :(得分:0)

如果在return false语句之前出现问题(抛出异常),浏览器将在您看到错误消息之前按照链接进行导航。这可能是IE中发生的事情。

对fancybox选项中的href属性进行硬编码,并让实际锚点的hrefjavascript:void(0);。这样,您就可以看到错误是什么。

答案 1 :(得分:0)

简单。

在你的$ .fancybox电话会议之前加上这个。

event.preventDefault();

这将阻止href触发。