Refreshig a parent window from an iframe.. is it possible?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jezternz
    New Member
    • Jan 2008
    • 145

    #1

    Refreshig a parent window from an iframe.. is it possible?

    Hey, The title really sums it up.
    I have a php script in an iframe I want to be able to refresh the parent window from the iframe.

    very simple example as follows:
    note its an example.

    Main.php
    [PHP]
    I want all content here to be refreshed
    <iframe scr="second.php "></iframe>
    [/PHP]

    Second.php
    [PHP]
    <? If a statement is true refresh parent page ?>
    [/PHP]
  • harshmaul
    Recognized Expert Contributor
    • Jul 2007
    • 490

    #2
    Hi,
    The problem you have here is that PHP runs on the server, and you want to execute a command on the client.

    You will need to print out some javascript to refresh the parent frame.

    something like this
    Code:
    window.parent.location.href = window.parent.location.href;
    So try this.....

    Code:
    <?php
    if(true){
    ?>
    <script language="text/javascript">
    window.parent.location.href = window.parent.location.href;
    </script>
    <?php
    }else{
    ?>
    <!--Do nothing-->
    <?php
    }
    ?>

    Comment

    • Jezternz
      New Member
      • Jan 2008
      • 145

      #3
      Thankyou very much, thats very helpful. I should have known this. Again thanks :)

      Comment

      • harshmaul
        Recognized Expert Contributor
        • Jul 2007
        • 490

        #4
        No problem, I'm here to help :)

        Comment

        Working...