IFrame

I want a small portion in my page to reload after every interval, how to do it?

Explanation

As in the question, some time we may face a situation where only a small portion or content of the page should be dynamically updated after every few seconds. Then it is not wise to load the full page. Then we go for iframe.
Here we do it in three steps
Step1:
Separate the content that needs to be updated dynamically in to a separate page.

Example:

itest.php
<html>
<head> </head>
<body bgcolor=green>
Dynamic Content Page
</body>
<html>

Step2:
Add auto refresh to this page.
i.e. copy the meta tag in to the header of the page. (e.g: itest.php)

Example:

itest.php
<meta http-equiv="refresh" content="5" >

Step3:
Set the dynamic page in to our main page using iframe.
Here we use tables and the iframe page is set in site one of the table columns.

Example:

ifexample.php
<html>
<body>
This is iframe test page. You can see that only the content in the below box, which is a iframe gets loaded after every 5 second. <br><br>
<iframe src="itest.php" width=100 height=100 frameborder=0 scrolling=no>
</iframe>
</body>
</html>

We would recommend the time of refresh be above 5 seconds. This is because we have to consider the page loading time.

Ask Questions

Ask Question