0

I've been trying to get Fancybox 2 to work with Firefox 22.0, however to no avail. I ran this with chrome, which turned out fine. I've downgraded the jQuery version, put https on the link, ran it through Firebug, nothing worked. Any ideas?

Javascript:

  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>

<script src="fancybox/jquery.fancybox.js?v=2.1.5"></script>
<script>
$(".fancybox").fancybox({
                openEffect  : 'none',
                closeEffect : 'none',
                afterClose    : function() {        
                    slideMove = true;                                  
                },
                beforeLoad : function() {
                    event.preventDefault(); 
                    slideMove = false;

                }
            });
</script>

HTML:

<a class="fancybox" href="images/screenshots/flower-big.jpg" title="The Cupertino Florist"><img src="images/screenshots/flower-small.jpg" alt=""></a>

Website: http://andrewgu12.kodingen.com/#portfolio

4

1 回答 1

0

您的 javascript 应该看起来像:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="fancybox/jquery.fancybox.js?v=2.1.5"></script>
<script>
$(document).ready(function (){
    $(".fancybox").fancybox({
        openEffect: 'none',
        closeEffect: 'none',
        afterClose: function () {
            slideMove = true;
        },
        beforeLoad: function () {
            event.preventDefault(); //<--- this is breaking your code in Firefox
            slideMove = false;
        }
    });
});
</script>

...假设您有 HTML5 DOCTYPE,否则将type="text/javascript"属性添加到您的script标签

编辑:好吧,它不是 Firefox 22,我忽略了您代码中的一些行:回调event.preventDefault();内部beforeLoad正在破坏您在 Firefox 中的代码。此JSFIDDLE不起作用,如果注释掉,这将起作用。

于 2013-07-26T05:17:53.303 回答