自动刷新IFrame HTML [英] Auto Refresh IFrame HTML

查看:250
本文介绍了自动刷新IFrame HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何每隔3秒自动刷新一次Iframe,而不刷新整个页面。我使用< meta http-equiv =refreshcontent =1> 但它会显示整个页面刷新并且每次都会将您带到页面顶部它确实。我的Iframe指向一个文本文件来读取我输入的实时消息。是否有一种方法可以解决整个页面的问题,只需要元素。我是一名HTML初学者,请详细解释。我谷歌很多,并尝试了很多东西,到目前为止没有任何作用,我尝试在许多浏览器。

How do I auto Refresh a Iframe every 3 Seconds with out it refreshing the entire page. I use <meta http-equiv="refresh" content="1"> but it shows the entire page refresh and puts you to the top of the page each time it does. My Iframe is pointed at a text file to read live messages I put in. Is there even a way to do this with out it refreshing the entire page, just the element. I am a HTML beginner so explain thoroughly please. I google alot and tried many things and so far nothing works and I try in many browser.

我的代码到目前为止:

<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="favicon.png" type="image/x-icon" />



<title>Chat</title>

<style>

body{
margin: 0px;
}

h1{
font-family: arial;
font-size: 100%;
}
iframe{
width: 900px;
height: 500px;
}

div.top{
background-color: rgba(2, 109, 8, 0.83);
height: 30px;
width: 100%;
}
</style>


</head>

<body>
<div class="top">
<img src="favicon.png" alt="favicon"  height="31" width="31" >
<h1>Chat</h1>
</div>




<iframe src="text.txt" name="iframe_a"> />



</body>
</html>


推荐答案

只需使用几个即可完成所需工作Javascript行。

You could accomplish what you need by simply using a few lines of Javascript.

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

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

这篇关于自动刷新IFrame HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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