An Iframe I need to refresh every 30 seconds (but not the whole page)

VK27 picture VK27 · Feb 28, 2011 · Viewed 111k times · Source

I have this bit of code

<iframe marginwidth="0" marginheight="0" width="240" height="80" scrolling="no" frameborder=0 src="irc_online.php">
</iframe>

I am adding this to a html widget I have on a sidebar, Is there a way I can make this refresh say every 30 seconds and not the rest of my page?

Answer

ahmet2106 picture ahmet2106 · Feb 28, 2011

You can put a meta refresh Tag in the irc_online.php

<meta http-equiv="refresh" content="30">

OR you can use Javascript with setInterval to refresh the src of the Source...

<script>
window.setInterval("reloadIFrame();", 30000);

function reloadIFrame() {
 document.frames["frameNameHere"].location.reload();
}
</script>