Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I have a web page and wish to autorefresh some of the content.

I currently am using:
HTML
<meta http-equiv="refresh" content="60" > 


This refreshes the whole page every minute, which is functionally ok.


However I have an iframe on the page and it is only the content of this iframe that I want to auto refresh.

What is the simplest way to do this?
Posted

CG is right. Alternatively you may use Javascript setTimeout so dynamically you may refresh the iframe
 
Share this answer
 
Comments
Dalek Dave 4-Feb-12 13:00pm    
Thanks, it seems that you cannot put a meta tag in an iframe and the way to do it is as I have edited about, using setTimeout as you seuggested.
Espen Harlinn 8-Feb-12 19:11pm    
5'ed!
Aha...

Thanks to Thatraja for his suggestion of setTimeout...

Here[^] is where I found salvation after having the setTimeout pointer.
 
Share this answer
 
Comments
Christian Graus 4-Feb-12 13:25pm    
You should know better than to post this as an answer..... Yes, the meta tag is something I've never used, if it didn't work, the other solution was to do it the old fashioned way
Dalek Dave 4-Feb-12 13:36pm    
Answer what way?

I just used the "I have solved this myself" button.
I didn't post as an "Answer".
Dalek Dave 4-Feb-12 13:36pm    
As for the old fashioned way, you have to remember I am an accountant, so a lot of the "old fashioned ways" are the "new fangled ways" :)
Put that tag inside your iframe page.
 
Share this answer
 
Comments
Dalek Dave 4-Feb-12 12:40pm    
I refuse to accept that it is that simple!

Is that it?

Really?
Dalek Dave 4-Feb-12 12:47pm    
OK tried it and it says that Meta cannot be nested in an iframe.
I'm a month late for the discussion, but Graus is right. It has to work (the meta inside the frame's html)
Here's a sample.
Save this one as page.htm
XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
  <div style="padding:25px;">
    <script>document.write(Date().toString());</script><br/>
    <iframe src="frame.htm" title="frame title"></iframe>
  </div>
</body>
</html>

& this one as frame.htm
XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="refresh" content="2" >
</head>
<body>
<script>document.write(Date().toString());</script>
</body>
</html>

Fire the page.htm & you'll see the refresh.

However this is not viable if the frame's html is used as another stand alone page & you do not want to insert the 'meta refresh' inside it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900