FancyBox iframe returns parent.$ as undefined (using WordPress)

前端 未结 9 2403
无人共我
无人共我 2020-12-04 01:58

I\'m trying to close FancyBox from within the iframe, but parent.$ is always undefined. This is my iframe JavaScript:

 

        
相关标签:
9条回答
  • 2020-12-04 02:26

    HI, Anyone who is having trouble closing a Fancy Box iFrame using a manual install of Fancy Box in Wordpress 3.0:

    Use this link in your iframe:

    <a href="#" onClick="parent.jQuery.fancybox.close();" title="Close window">close fancybox</a>
    

    It works :)

    0 讨论(0)
  • 2020-12-04 02:28

    I had to do this:

    window.top.window.$.fancybox.close();

    Got type error before.

    0 讨论(0)
  • 2020-12-04 02:39

    My answer is not related to wordpress, but one for fancybox in general.

    in the iframe, if you have included the main jquery script(jquery-1.5.2.min.js), then it will conflict with the one on the main page, and parent.$.fancybox will not work in this case.

    other jquery related stuff (like for eg: the tabs) will work inside the iframe. hence, it wont occur to a novice programmer that the second jquery script inside the iframe is the villain.

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