Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

need an iframe to refresh automatically

I have a situation where I need to refresh an iframe about every 30 seconds. I have looked through the forums and tried a few things, to no avail.

<iframe id="Doyle" src="http://www.dot.ca.gov/dist2/rwis/sm_doyle.php" 
width="375" height="560">
</iframe>

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

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

Any suggestions on how to make this work?

like image 543
Tyler Tracy Avatar asked May 22 '26 22:05

Tyler Tracy


1 Answers

Use following code

<iframe id="Doyle" src="http://www.dot.ca.gov/dist2/rwis/sm_doyle.php" 
width="375" height="560">
</iframe>

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

function reloadIFrame() {
 var frameHolder=document.getElementById('Doyle');
frameHolder.src="http://www.dot.ca.gov/dist2/rwis/sm_doyle.php"
}
</script>

check working example below

http://plnkr.co/edit/Mre0AgMjh5o7wXl5YvVP?p=preview

like image 183
Vikas Sardana Avatar answered May 25 '26 11:05

Vikas Sardana



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!