Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 553
  • Last Modified:

Refresh iframe content automatically

I have an iframe which i want to refresh every 2 seconds.

lets say

<iframe src="http://www.yahoo.com">
</iframe>

i wanna load only the iframe. now i dont have control on the other url (src)

I dont know how meta refresh will work.
0
tgatif
Asked:
tgatif
1 Solution
 
shaggy_the_sheepCommented:
Hi

You could use a JavaScript function to re-enter the src of the iframe, thus reloading it.

var timer; function reloadFrame(){

document.getElementById('myFrame').src = 'http://www.yahoo.com';

clearTimeout(timer)
timer = setTimeout('reloadFrame()',2000)
}

now change your iFrame to this:
<iframe id="myFrame" src="http://www.yahoo.com">
</iframe>

And call the function onload
<body onload="reloadFrame()">

Let me know if this works okay

Richard
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now