如何自動刷新一個iframe每3秒刷新整個頁面。我使用<meta http-equiv="refresh" content="1">
,但它會顯示整個頁面刷新,並在每次刷新頁面時將其顯示在頁面頂部。我的iframe指向一個文本文件來讀取我放入的實時消息。是否有辦法做到這一點,刷新整個頁面,只是元素。我是一個HTML初學者,請詳細解釋。我谷歌很多,並嘗試了很多東西,迄今沒有任何作品,我嘗試在許多瀏覽器。自動刷新IFrame HTML
到目前爲止我的代碼:
<!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>
你應該看看[這個問題](http://stackoverflow.com/questions/25446628/ajax-jquery-refresh-div-every-5-seconds)。 – Berendschot
http://stackoverflow.com/q/86428/2517622 – drets
仍然沒有幫助。同樣的事情 –