WordPress.org

Ready to get started?Download WordPress

Forums

Easy FancyBox
[resolved] close from child window and resize (2 posts)

  1. sauronz
    Member
    Posted 3 years ago #

    Hi.

    Is there any way to close the fancybox iframed window from the child one?

    Is the any way to resize the window from the child?

    I have tried a few ways, but no chance.

    $.fn.fancybox.close();
    window.parent.$.fancybox.close();
    parent.jQuery.fn.fancybox.close();
    $.fancybox.resize();

    Thnx for your help

  2. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    In theory, the javascript code parent.$.fancybox.close(); called from the iframe content should cause FancyBox to close, similarly with parent.$.fancybox.resize(); but ... this is not true in all cases!

    For example, if the iframe content is a web page from another domain (other website) this will not work. The call is intercepted and blocked to prevent a real world security issue called "cross-site scripting".

    Is your iframe content pulled from another domain than the domain of the original page from where you open FancyBox?

    If so, there might still be a way: create a file in your site root called crossdomain.xml filled with:

    <?xml version="1.0"?>
    <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
    <cross-domain-policy>
        <site-control permitted-cross-domain-policies="all"/>
        <allow-access-from domain="*.the-other-domain.com" />
    </cross-domain-policy>

    Where you replace the text *.the-other-domain.com with that other domain name. The * is a wild-card to allow a wider scope of sub-domains (including www) for example, but can also be used on its own to allow access for ALL domains out there. But be warned, allowing cross domain access to sites you do not trust, DOES bring along a security issue! Read/search on Google for more...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic