<html>
<script language="javascript" >
var checkfreq=1;//队列检查频率,默认1秒检查一次
var brun=false;//防止同一时间同时运行2个程序
function runurl(strurl,strfreq)
{
this.url=strurl;//运行的url
this.freq=strfreq;//运行频率
this.lastrun='';//上次运行时间
}
var runqueue = new array();
function addrun(strurl,strfreq)//添加run
{
if(strurl==''||strfreq=='')return
runqueue[runqueue.length]=new runurl(strurl,strfreq)
}
function run(url)//运行url
{
var xmlhttp;
if (window.xmlhttprequest)xmlhttp = new xmlhttprequest();
else if (window.activexobject)xmlhttp = new activexobject("microsoft.xmlhttp");
xmlhttp.onreadystatechange = function(){brun=false;}
xmlhttp.open("get", url, true);
xmlhttp.send(null);
brun=true;
}
function checkrun()//检查队列
{
var dtnow=new date(),objrun;
var tnow=dtnow.gettime();
for(var i=0;i<runqueue.length;i++)
{
objrun=runqueue[i];
if(objrun.lastrun=='')objrun.lastrun=tnow;
if(!brun&&(objrun.freq==0||(tnow-objrun.lastrun)>objrun.freq*1000))
{
objrun.lastrun=tnow;
run(objrun.url);
}
}
}
addrun('http://publish.sina.com.cn/poll.php?p_id=413&t_id=119',10);
setinterval('checkrun()',checkfreq*1000);//setinterval
</script>
<script language="javascript" >
<!--
function clock(){
i=i-1
document.title="after "+i+" minitues,this window will closed self!";
if(i>0)settimeout("clock();",20000);
else {window.opener=null;self.close();}
}
var i=2
clock();
-->
</script></html>