Search code examples
iframeprettyphoto

Refresh parent page from prettyPhoto iframe


I have a parent page that calls an iframe modal window as follows:

<script type="text/javascript" charset="utf-8">
                            $(document).ready(function(){
                                $("a[rel^='prettyPhoto']").prettyPhoto();
                            });

</script>

When the iframe is closed, I want the parent page to refresh.

What code do I need to add to the iframe? Do I need to create a callback function on the parent page first?


Solution

  • if you look closely at the source, prettyphoto wraps the iframe in a div that contains all the buttons. the only part that is iframed is the actual content. The close button is contained in the parent page. You will need to add an event handler to .pp_close click event.

    <script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
      $("a[rel^='prettyPhoto']").prettyPhoto();
      $(".pp_close").click(function () {
        document.location.reload(true);
      });
    });
    </script>