Jump to content

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.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.