Search code examples
jqueryfancyboxhreflocation-href

FancyBox close from within iframe and take parent page to the link


I found applying the following function to a links onclose works to close Fancybox from within an iFrame: parent.$.fancybox.close();

I want to take this further and have the link take the parent page to a new url. I've tried the following but it doesn't work:

<a onclick="location.href='http://www.domain.com/page/';parent.$.fancybox.close();"> Close and go to page</a>

using a href doesn't work either as the onclose takes precedence.


Solution

  • Very simple solution... can't believe I didn't think of this!!!

    <a href="http://www.domain.com/page/" target="_parent"> Close and go to page</a>
    

    Sometime, I swear I try to make things more difficult than they actually are!