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

前端 未结 9 2401
无人共我
无人共我 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:13

    None of the suggestions worked for me. I had to work around it using the following code. The latest version may be supporting the parent.jQuery.fancybox.close(); approach, but the older versions do not work with that.

    For existing sites with older versions of the plugins/Jquery, try this

    function close_window()
    {
     $("#fancy_outer",window.parent.document).hide();
     $("#fancy_overlay",window.parent.document).hide();
     //window.top.window.$.fancybox.close(); this also does not work :(
    }
    

    you could declare and use the function close_window within the Iframe content.

提交回复
热议问题