function loadXmlHttp(url,id) { var f = this; f.xmlHttp = null; if (window.XMLHttpRequest&&!f.ie||/^http/.test(window.location.href)) f.xmlHttp = new XMLHttpRequest(); else if (/(object)|(function)/.test(typeof createRequest)) f.xmlHttp = createRequest(); else { f.xmlHttp = null; } if(f.xmlHttp != null) { f.el = document.getElementById(id); f.xmlHttp.open("GET",url,true); f.xmlHttp.onreadystatechange = function(){f.stateChanged();}; f.xmlHttp.send(null); } } loadXmlHttp.prototype.stateChanged=function () { if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href))) this.el.innerHTML = this.xmlHttp.responseText; } var requestPic = function() { new loadXmlHttp('getpic.php','picDiv'); setInterval(function(){new loadXmlHttp('getpic.php', 'picDiv');}, 6000); } if (window.addEventListener) window.addEventListener('load',requestPic,false); else if (window.attachEvent) window.attachEvent('onload',requestPic);