A friend entrusted me to vote for him:
Http://publish.sina.com.cn/04/13/413/search.php
The voting link is:
Http://publish.sina.com.cn/poll.php? P_id = 413 & t_id = 119
I made the following code and made it into a task manager. I opened it once every one minute and closed the window automatically. But the actual operation was ineffective and I don't know where the problem was?
Copy codeThe Code is as follows: <Script language = "javascript">
Var CheckFreq = 1; // The queue check frequency. The default value is 1 second.
Var bRun = false; // prevents two programs from running at the same time
Function RunUrl (strUrl, strFreq)
{
This. url = strUrl; // The Running URL
This. freq = strFreq; // running frequency
This. lastrun = ''; // last running time
}
Var RunQueue = new Array ();
Function AddRun (strUrl, strFreq) // Add Run
{
If (strUrl = ''| strFreq ='') return
RunQueue [RunQueue. length] = new RunUrl (strUrl, strFreq)
}
Function Run (url) // Run the 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 () // check the queue
{
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>