Código:
<script> var seconds = 0.1; var divid = "timediv"; var url = "MostrarMensajes.php"; function refreshdiv(){ var xmlHttp; try{ xmlHttp=new XMLHttpRequest(); } catch (e){ try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("Tu explorador no soporta AJAX."); return false; } } } fetch_unix_timestamp = function() { return parseInt(new Date().getTime().toString().substring(0, 10)) } var timestamp = fetch_unix_timestamp(); var nocacheurl = url+"?t="+timestamp; xmlHttp.onreadystatechange=function(){ if(xmlHttp.readyState==4){ document.getElementById(divid).innerHTML=xmlHttp.responseText; setTimeout('refreshdiv()',seconds*1000); } } xmlHttp.open("GET",nocacheurl,true); xmlHttp.send(null); } window.onload = function startrefresh(){ setTimeout('refreshdiv()',seconds*1000); } </script> <div name="timediv" id="timediv"> </div>