刷新iframe而不丢失's text/flickering


Refresh an iframe without losing it's text/flickering

我运行一个电台网站,我正试图使它的内容(电台信息)自动刷新。

当前刷新时非常难看。

我希望它保持广播信息的iframe的内容,直到它完成刷新。

下面是我的代码:PHP中包含iframe的内容:http://pastebin.com/fwBjMEUs

要刷新的Radio Info PHP: http://pastebin.com/XyfhG8Kn

最好使用AJAX。它使用div而不是iFrame作为容器。只要确保PHP文件只输出div内所需的HTML,然后将此脚本添加到要显示它的页面:

<script>
function refreshinfo(){
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("currentinfo").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","http://www.x86cam.com/wp-content/plugins/radio-info.php",true);
xmlhttp.send();
}
setInterval(refreshinfo, 20000); /*How often to refresh in ms; currently 20 secs */
</script>

然后用<div id="currentinfo"></div>替换你的iframe,你应该都设置好了!

编辑:我已经检查了php页面,你拉的信息,所有你需要做的就是删除<centre></centre>标签从它我认为,但它可能工作留在!