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 requestText=function() { new loadXmlHttp('getpic.php?id=1','picDiv'); setInterval(function(){new loadXmlHttp('getpic.php?id=1', 'picDiv');}, 30000); } if(window.addEventListener) window.addEventListener('load',requestText,false); else if(window.attachEvent) window.attachEvent('onload',requestText);