Alot of people have been telling me for an auto refresh with no flicker on refresh in ie to use ajax i finally spent hours finding a code that worked and figured out the images still flicker on refresh, it dosnt output smoothly, what do i do to make it smooth refresh its for my chatroom:

Code:
<head>
<script type="text/javascript">
var page = "test2.php";
function ajax(url,target)
 {
    // native XMLHttpRequest object
   document.getElementById(target).innerHTML = '';
   if (window.XMLHttpRequest) {
       req = new XMLHttpRequest();
       req.onreadystatechange = function() {ajaxDone(target);};
       req.open("GET", url+"?sid="+Math.random(), true);
       req.send(null);
   // IE/Windows ActiveX version
   } else if (window.ActiveXObject) {
       req = new ActiveXObject("Microsoft.XMLHTTP");
       if (req) {
           req.onreadystatechange = function() {ajaxDone(target);};
           req.open("GET", url+"?sid="+Math.random(), true);
           req.send();
       }
   }
         setTimeout("ajax(page,'scriptoutput')", 2000);
}

function ajaxDone(target) {
   // only if req is "loaded"
   if (req.readyState == 4) {
       // only if "OK"
       if (req.status == 200 || req.status == 304) {
           results = req.responseText;
           document.getElementById(target).innerHTML = results;
       } else {
           document.getElementById(target).innerHTML="ajax error:\n" +
               req.statusText;
       }
   }
}
</script>
</head>
<body onload="ajax(page,'scriptoutput')">
<span id="scriptoutput"></span></p>
</body>