By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

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

Jezternz
100+
P: 145
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]
Feb 14 '08 #1
Share this Question
Share on Google+
3 Replies


harshmaul
Expert 100+
P: 490
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
Expand|Select|Wrap|Line Numbers
  1. window.parent.location.href = window.parent.location.href;
So try this.....

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(true){
  3. ?>
  4. <script language="text/javascript">
  5. window.parent.location.href = window.parent.location.href;
  6. </script>
  7. <?php
  8. }else{
  9. ?>
  10. <!--Do nothing-->
  11. <?php
  12. }
  13. ?>
Feb 14 '08 #2

Jezternz
100+
P: 145
Thankyou very much, thats very helpful. I should have known this. Again thanks :)
Feb 15 '08 #3

harshmaul
Expert 100+
P: 490
No problem, I'm here to help :)
Feb 15 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.