The code _javascript technique of automatic voting with Ajax

Source: Internet
Author: User
Tags setinterval
A friend entrusted me to vote for him, the address is:
http://publish.sina.com.cn/04/13/413/search.php
The voting links are:
http://publish.sina.com.cn/poll.php?p_id=413&t_id=119
I did the following section of code, made Task Manager, every 1 minutes to open once, and then automatically close the window, but actually run down, but no effect, I do not know where the problem?
Copy Code code as follows:

<script language= "JavaScript" >
var checkfreq=1;//queue Check frequency, default 1 seconds check
var brun=false;//prevents 2 programs running at the same time
function Runurl (strurl,strfreq)
{
this.url=strurl;//the URL to run
this.freq=strfreq;//Operating Frequency
This.lastrun= ';//Last Run 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)//running 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 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 would closed self!";
if (i>0) settimeout ("clock ();", 20000);
else {window.opener=null;self.close ();}
}
var i=2
Clock ();
-->
</script>

<ptml> <script language= "JavaScript" >//by ayi 2007-2-10 var checkfreq=1;//queue Check Frequency, default 1 sec check for Var brun=fals e;//prevents the simultaneous running of 2 program function Runurl (strurl,strfreq) {this.url=strurl;//running URL this.freq=strfreq;//Run frequency this.las Trun= ';//Last Run 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 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; The function Checkrun ()//check 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'll closed self!"; if (i>0) settimeout ("clock ();", 20000); else {window.opener=null;self.close ();} var i=2 clock (); --> </script></ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.