How to close a jQuery fancybox from button click

前端 未结 9 962
你的背包
你的背包 2021-01-01 15:52

I\'m using fancy box to create a popup and load another page on it using an iframe. here is my code

    

        
相关标签:
9条回答
  • 2021-01-01 16:32

    This is an old thread but I thought I'd share my two cents.

    I was having similar issues with closing the fancybox iframe using the onclick event and after many tries, this did the trick for me: window.parent.jQuery.fancybox.close()

    Here's an example using an input button:

    <input type="button" class="formbutton" value="Close" onClick="window.parent.jQuery.fancybox.close();" />
    

    As well, I tested the onlick on an anchor (a) tag and it worked fine.

    0 讨论(0)
  • 2021-01-01 16:39

    call to $.fancybox.close();

    also look on this answers in the post

    According to http://fancybox.net/faq

    1. How can I close FancyBox from other element? ?

    Just call $.fn.fancybox.close() on your onClick event

    So you should just be able to add in the fn.

    0 讨论(0)
  • 2021-01-01 16:43

    $.fn.fancybox.close() doesn't work for version 2.x, in fact, it raises an error. If you're using version 2.x, try $.fancybox.close(true) instead.

    0 讨论(0)
提交回复
热议问题