0

I know it's a common question, and also I have already read a lot of discussions before starts this.

I have an iframe (inside a div) that show part of an external website. If I stay on my page, the website inside my iframe refresh the data every 30 seconds. If I don't stay on the page, the page will not auto refresh every 30.

My focus is to refresh the iframe every 10 seconds, so I'm sure that what I see is update.

That's my index.htm but I'm not sure if it works. Do you find any errors in the iframe refresh part?

<!doctype html>
<html lang="en">
<head>
 <meta charset="utf-8">
 <title>TITLE</title>
 <meta name="apple-mobile-web-app-capable" content="yes">
<style>
div{
width:1000px;
height:450px;
position:relative;
border: 1px solid black;
overflow:hidden;
margin-right: auto;
margin-left: auto;
}

iframe{
position:absolute;
width:1280px;
height:1400px;
top:-915px;
left:-240px;
}
</style>
</head>
<body>

<div>
<iframe name="myIframe" src="https://website.com" scrolling="no" frameborder="no"> </iframe>
</div>

<script>
window.setInterval("reloadIFrame();", 10000);
function reloadIFrame() {
 document.frames["myIframe"].location.reload();
}
</script>

</body>
</html>
Dinal Koyani
  • 455
  • 3
  • 6
Andrea
  • 1
  • 2
  • 1
    `window.setInterval(function () { reloadIFrame() }, 10000);` should work – Igor Soloydenko Oct 17 '17 at 11:10
  • As a side-note: don't use `setInterval("reloadIFrame();", 10000)`. Pass the function as a reference, instead: `setInterval(reloadIFrame, 10000)` – Cerbrus Oct 17 '17 at 11:12
  • @Cerbrus i tried your solution, but it doesnt work. Is this all correct?
    – Andrea Oct 17 '17 at 12:20

0 Answers0