Hi all,
The code below refreshes mypage.php every 3 seconds without blinking or anything you can notice when seeing the page.
This is working for all browsers except for Internet Explorer 6. When using IE6 the text in mypage.php does not move but the images blink with every refresh.
Here's the page:
http://vivocom.es/test/prensa/index_autorefresh.html
Any ajax genius can modify the script so it can work also for Internet Explorer 6? or even make a new script for Internet Explorer 6 ( I'll detect the browser and I'll show one or the other)..
Thanks a ton in advance!
Code:
<script type="text/javascript">
function getHTTPObject() {
var request = false;
try {
request = new ActiveXObject('Msxml2.XMLHTTP');
}
catch (err2) {
try {
request = new ActiveXObject('Microsoft.XMLHTTP');
}
catch (err3) {
try {
request = new XMLHttpRequest();
}
catch (err1)
{
request = false;
}
}
}
return request;
}
var ajaxRequest = getHTTPObject(); // creating HTTP Object
setInterval(getPage, 3000); // 3 secs
function getPage() {
// ajaxRequest.open("GET", "mypage.php", true);
ajaxRequest.open("GET", "mypage.php"+"?dummy="+new Date().getTime(), true)
ajaxRequest.onreadystatechange = showPage;
ajaxRequest.send(null);
}
function showPage()
{
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('show');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
window.onload=function(){
getPage();
}
</script>
</head>
<body>
<div id="show" ></div>
mypage.php
Code:
<?php
echo"Here a text that don't blink but the image below does it (when using IE6) every 3 seconds
<br><br><img src='http://dertompson.com/wp-content/uploads/2008/03/memory-verlauf-ie-reload.png'>";
?>