Close prettyPhoto from iFrame
  • Hi Guys, I need to close an instance of prettyPhoto from within the iframe it's launched, without using the close button. I've tried using the api but am guessing it's out of scope within the launched iframe. I'd be grateful if anyone can help.
  • I'd like to the the same thing.

    Example: A login page is loaded in the iframe with prettyPhoto, when the user is successfully logged in, I'd like the to redirect to a new page in the parent window and close the iframe.

    At the moment, my site loads the redirected page in the iframe.. :(

    Does anyone know how this can be achieved? Thanks.
  • If you want to close it by the click of a URL, it can be done by setting the target of the link:



    More specifically what I'm trying to accomplish though is something similar to a php redirect opening up in the parent window, rather than in the iframe. So that the user doesn't have to click a link, or close for the window to go away.

    Any help would be much appreciated. Thanks.
  • hi
    please did you find solution for your exemple Audesi
    Example: A login page is loaded in the iframe with prettyPhoto, when the user is successfully logged in, I'd like the to redirect to a new page in the parent window and close the iframe.
    Because i have the same probleme thx for your help
  • I have been trying to figure this out for like 2 months. I give up!
  • hi i find the solution juste add in page of authentification

    parent.window.location.href="index.php";

    or do this Register
    good luck
  • Same problem here with asp though, where would I insert parent.window.location.href="index.php";

    Kind regards
  • Hi,
    Ive got this working - its quite straight forward
    from the page in the iFrame if they click a link or button call some javascript

    window.parent.closeTheIFrameImDone();

    Then in your parent page (The page that kicked off the iframe) have a javascript function thus

    function closeTheIFrameImDone()
    {
    jQuery.prettyPhoto.close();

    // Now crack on with whatever
    }

    This is also an easy way for the child page to send values back to the parent page just give the closeTheIFrameImDone function some parameters

    Hope this helps
  • Hi, thanks for your reply, I managed to get it going with this isnide the iframe.


    window.top.location = 'parentwindow.asp';


    All sorted
  • For vb.net I was able to do this onclick
    ClientScript.RegisterStartupScript(Me.GetType(), "Redirect", "parent.window.location.href='default.aspx';", True)
  • Register a script in your parent document (the one hosting the prettyphoto box)

    function closeBox() {
    $.prettyPhoto.close();
    }

    To call it from the iframe
    <a href="#" onclick="window.top.closeBox();">Close</a>
  • Michael, thanks a lot, that helped
  • No needing to create function. Close your pretty from the iframe with :
    Close
  • I want to pass some click event from this close event to parent window , how can this be possible?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!