每5分钟重复自动刷新IFrame



我有一个iframe,我需要每五分钟刷新一次。我有下面的,但它只刷新时间。我需要它每五分钟刷新一次。

<table class="auto-style7">
<tr>
<td class="auto-style4">
</td>
</tr>
<tr>
<td class="auto-style2">
<p class="auto-style13" style="text-align: center; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-indent: 0px; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
Map does not auto-refresh.&nbsp; To update map you will need to manual refresh the page. (Click on warnings to get full details)</p>
<iframe width="1850" src="website url" class="auto-style8" height="650">
<script type="text/javascript">
function refreshiframe() 
{ 
parent.frame1.location.href ="website url" 
setTimeout("refreshiframe()",3000); 
} 
</script>
<body  onload="refreshiframe();">
</iframe>
<br />
</td>
</tr>
</table>
&nbsp;
<br />```

我找到了解决方案。通过将正确的脚本放在iframe之前,并给iframe一个id:

<script>
function reload() {
document.getElementById("ifr").src = "website url"
}
setInterval(reload, 60000)
</script>
<table class="auto-style7">
<tr>
<td class="auto-style4">
</td>
</tr>
<tr>
<td class="auto-style2">
<p class="auto-style13" style="text-align: center; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-indent: 0px; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
Map auto-refreshes every 5 minutes.&nbsp; Warnings update every minute (Click on warnings to get full details).</p>
<iframe width="1850" src="website url" class="auto-style8" height="650" id="ifr"></iframe>
<br />
</td>
</tr>
</table>
&nbsp;
<br />```

最新更新