Fancybox无限循环-无法读取未定义的属性"href" [英] Fancybox infinite loop - Cannot read property 'href' of undefined

查看:138
本文介绍了Fancybox无限循环-无法读取未定义的属性"href"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试通过fancybox行为向我的网站添加灯箱,但是在单击要使用FF或Chrome浏览器进行灯箱包装的图像后,使用JS探查器进行检查,我进入了一个无限循环,出现此错误:

I'm trying to add a lightbox via fancybox behavior to my site, but inspecting with a JS profiler after clicking on the image to be lightboxed with FF or Chrome, I get into an infinite loop with this error:

Cannot read property 'href' of undefined

尽管,图像会被加载,尽管在关闭时会出现错误,有时会导致浏览器崩溃,但是无限次的这些调用并在HTML源代码中重新创建图像会导致这种情况的发生.

Images are however loaded, although with bugs when closing or with crashing the browser sometimes, but the infinite number of these calls and recreating the images in the HTML source code causes this to happen.

这是我的带有图片的HTML:

This is my HTML with images:

<div class="below_shadow" style="top: 0px;">
    <a class="portfolio_link" href="http://mywebsite.com/images/DSC_0258-794x1024.jpg">
    <img class="frame" alt="" src="http://mywebsite.com/images/DSC_0258-794x1024.jpg&amp;h=131&amp;w=180&amp;zc=1" style="top: 0px;">
    </a>
    <span style="display: none;" class="portfolio4_hover">
        <a style="top: 0px; " class="portfolio_image" href="javascript:;">
            <img alt="" src="http://mywebsite.com/images/icon_zoom.png">
        </a>
    </span>
</div>

这是我在JS部分中的电话:

And this is my call in the JS section:

jQuery(window).load(function() {
jQuery('.below_shadow a.portfolio_link').fancybox({ 
    padding: 0,
    overlayColor: '#000', 
    transitionIn: 'elastic',
    transitionOut: 'elastic', 
    overlayOpacity: .8,
    showNavArrows: true
});
});

推荐答案

我发现了错误-计算此代码时将调用无限循环:

I found out the error - the infinite loop is called when this code is evaluated:

jQuery(this).find('.portfolio4_hover').show();

老实说-不知道为什么,但这是事实.如果我评论此行(下面是隐藏行),则一切正常.

Honestly - dunno why, but this is the case. If I comment this line (and it's hide line below), everything works correctly.

这篇关于Fancybox无限循环-无法读取未定义的属性"href"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆