Sunday, September 7, 2008

How to reload parent window from a iframe

Lets see how we can reload or refresh parent page from a iframe. This is pretty simple with small piece of JavaScript - top.location.href
Look at the following code it has two pages.

frame.htm - parent


<HTML>
<HEAD>
<TITLE>Parent window</TITLE>
</HEAD>
<BODY>

<table border="1">
<tr>
<td>This is main</td>
<td><iframe src ="frame2.htm" width="100%">
</iframe></td>
</tr>
</table>

</BODY>
</HTML>



frame2.htm


<HTML>
<HEAD>
<TITLE>New Document</TITLE>
</HEAD>
<BODY>

<div onClick="top.location.href='frame.php'">
Click here to reload parent page</div>

</BODY>
</HTML>


Get Free Sinhala IT Learning Videos Kuppiya.com



Get custom programming done at GetAFreelancer.com!

8 comments:

  1. Mmmmmm..
    what if :
    1. in main page there is a table
    2. in that iframe there's a form
    and when a button in iframe submitted, i want the table in main page refresh it self..
    anyone..
    thx
    :)

    ReplyDelete
  2. Do you want to reload only the table?

    ReplyDelete
  3. no..no...
    i knew whats wrong with it..
    thx..
    thx..
    thx..

    ReplyDelete
  4. Many thanks, saved me lots of time!
    Maks

    ReplyDelete