How to refresh an iframe not using javascript?

大城市里の小女人 提交于 2019-12-23 22:19:39

问题


I have an iframe which I would like to refresh every fifteen seconds, but I'm not sure how to do this or if it is even possible. If it is, how would I go about doing this without the use of JavaScript. If JavaScript is necessary then please post how I would do it in JavaScript. Thank you.


回答1:


You might be able to achieve this using a meta tag, inside the HEAD element of the HTML file being included inside the iframe:

<meta http-equiv="refresh" content="5" />

This will refresh the page every 5 seconds. See the Wikipedia entry.

However, using JavaScript, this is the way to go:

function reloadIframe() {
    var iframe = document.getElementById('my-iframe');
    iframe.src = "http://some/url/";
    setTimeout("reloadIframe()", 5000);
}
window.onload = reloadIframe;

This will reload the iframe with ID my-iframe every five seconds, by pointing it to http://some/url.



来源:https://stackoverflow.com/questions/8872126/how-to-refresh-an-iframe-not-using-javascript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!