如何使用javascript刷新iframe? [英] How to refresh an iframe not using javascript?

查看:110
本文介绍了如何使用javascript刷新iframe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iframe,我想每15秒刷新一次,但我不知道该怎么做或者甚至可能。如果是,我将如何在不使用JavaScript的情况下这样做。如果需要JavaScript,请发布我将如何在JavaScript中执行此操作。谢谢。

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.

推荐答案

您可以使用元标记在包含的HTML文件的HEAD元素内实现此目的在iframe内:

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" />

这将每5秒刷新一次页面。请参阅维基百科条目

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

但是,使用JavaScript,这是要走的路:

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;

这将重新加载ID my-iframe 每隔五秒,将其指向 http:// some / url

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

这篇关于如何使用javascript刷新iframe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆