开发者

Cancel FancyBox on PageLoad

I have a FancyBox set up on my site, but it is opening on PageLoad as opposed to what I want which is for it to be triggered by a click. I'm a total novice with jQuery and javascript, etc, so bear with me here. Below is the code I already have set up:` 开发者_开发知识库

        $(document).ready(function() {
            $(".iframe").fancybox({ 
            'transitionIn'  :   'elastic',
            'transitionOut' :   'elastic',
            'speedIn'   :   600, 
            'speedOut'  :   200, 
            'overlayShow'   :   true,
            'autoScale' :   true,
            'width'     :   '50%',
            'height'    :   '90%',
            'overlayOpacity':   0.8,
            'centerOnScroll':   true,
            'showCloseButton':  true

            });


            $(".iframe").trigger('click');
        });

`


The code

$(".iframe").trigger('click');

Causes a 'click' event to be generated on the load, just remove that line.


$(document).ready(function() {

    $(".iframe").fancybox({ 
    'transitionIn'  :   'elastic',
    'transitionOut' :   'elastic',
    'speedIn'   :   600, 
    'speedOut'  :   200, 
    'overlayShow'   :   true,
    'autoScale' :   true,
    'width'     :   '50%',
    'height'    :   '90%',
    'overlayOpacity':   0.8,
    'centerOnScroll':   true,
    'showCloseButton':  true

    });

  $('a.trigger').click( function(e) {
    e.preventDefault();
    $(".iframe").trigger('click');
  });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜