Jump to content

Refresh individual iframes?


matfish

Recommended Posts

Hi, Iv got a simple standard page (html) with a few iframes which pulls in different stats (its a work related thing).

 

I want to update one of the iframes only. Putting a meta refresh within that one iframe still reloads the whole page.

 

Im new to Ajax, anyone know of how to refresh one 1 iframe on a timer?

 

Many thanks

Link to comment
https://forums.phpfreaks.com/topic/45419-refresh-individual-iframes/
Share on other sites

Refreshing with AJAX pretty much removes the need for the iframe.  Either way, all you need to do is use a javascript timer to call a refresh javascript function.  In your response function, simply restart the timer.

 

Play with the example here: http://www.phpfreaks.com/forums/index.php/topic,115581.0.html

 

Then once you've written some of the code yourself, ask again.

Thank you both. I thought this would be an Ajax thing but javascript seemed to handle it:

 

<html>
<head>
<script type="text/javascript">

//Example to show 2 iframes, which the google iframe is being refreshed on its own

var reloadInterval = 3000;
function init() {
setTimeout('reload()',reloadInterval);
}

function reload() {
var iframe = document.getElementById('window1');
if (!iframe) return false;
iframe.src = iframe.src;
setTimeout('reload()',reloadInterval);
}

window.onload = init;
</script>

</head>
<body>

<iframe id="window1" width="500" height="400" src="http://www.google.com/"/></iframe>

<iframe id="window2" width="500" height="400" src="http://www.yahoo.com/"/></iframe>

</body>
</html>

 iframe.src = iframe.src;

Done that before, and one thing I can tell you is that if the user uses the backpage afterwards, the results will be very ugly! The backpage will load the iframe src as the whole page. Definitely very confusing for the user.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.