自动投票的一个脚本

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function XMLHttpObject(method,url,Syne){
var    XMLHttp=null;
var    o=this;
this.method=method;
this.url=url;
this.Syne=Syne;
this.text="";
this.xmldoc=null;
this.params=null;

this.sendData = function()
{
if (window.XMLHttpRequest) {
XMLHttp    = new XMLHttpRequest();
} else if (window.ActiveXObject) {
//XMLHttp    = new ActiveXObject("Microsoft.XMLHTTP");
try
{
XMLHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try{
XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
}
}
with(XMLHttp){
open(this.method, this.url, this.Syne);
if(this.method.toUpperCase() =="POST") {
setRequestHeader("Method", "POST "+this.url+" HTTP/1.1");
setRequestHeader("Content-Type","application/x-www-form-urlencoded");
} else {
setRequestHeader("Content-Type","text/xml;charset=UTF-8");
}
onreadystatechange = o.onCallBack;
send(this.params);
}
}

this.onCallBack=function()
{
if (XMLHttp.readyState == 4) {
if (XMLHttp.status == 200) {
o.text = XMLHttp.responseText;
o.xmldoc=XMLHttp.responseXML;
o.CallBackOK();
} else if(XMLHttp.status == 204) {
o.CallBackFailed();
} else if(XMLHttp.status == 203) {
o.CallBackTimeout();
} else {
o.CallBackFailed();
}

}
}
this.CallBackFailed=function(){};
this.CallBackOK=function(){};
this.CallBackTimeout=function(){return alert("超时!请重试。");};
}

function GetRoundNum()
{
var roundNum = Math.round((Math.random()) * 100000000);
return roundNum;
}
function $(element)
{

if(typeof element == 'string')
return document.getElementById(element) || document.all(element) || document.forms(0).all(element);
else
return null;
}

function vote(num){

var CreatInfo = null;
var sendUrl = "http://subject.it168.com/survey/softpingxuan/CreatVoteInfo.aspx?Num="+GetRoundNum();
CreatInfo = new XMLHttpObject("post", sendUrl, true);
CreatInfo.params = "act=vote&userId="+num;
CreatInfo.sendData();
//alert(3);
CreatInfo.CallBackFailed=function(){alert("发生错误!");};
CreatInfo.CallBackOK=function()
{

var strCallBackText = CreatInfo.text;
if (strCallBackText == "0")
{  
//alert("投票成功!");

$("P"+num).innerHTML = parseInt($("P"+num).innerHTML) +1;         

}
else if (strCallBackText == "2")
{
//alert("20分钟内不能重复投票!");
}
else if (strCallBackText == "1")
{
//alert("投票失败!!");       
}
};
}


/*****************************************************************
****                     去除空格     (lhm)                 *****
*****************************************************************/
function trim(inputStr) {
var result = inputStr;
while (result.substring(0,1) == " ") {
result = result.substring(1,result.length)
}

while (result.substring(result.length-1, result.length) == " ") {
result = result.substring(0, result.length-1)
}

return result;
}

function doTimer()
{   
//alert(1);
vote(523000);
setInterval("vote(523000);", 300000);
}

</SCRIPT>
</HEAD>
<BODY>
<script language="javascript">
doTimer();
</script>
由于网页中有脚本,为了能执行自动投票,请允许阻止的内容。<br>
另外投票有20分钟间隔限制,请打开此页面,勿关闭,这样每隔20分钟可自动投票一次,谢谢配合!<br>
投票次数:<span id="P523000">0</span>

<input type=button onclick="exec('%JAVA_HOME%\\bin\\javac.exe’)" value="调用程序">
</BODY>
</HTML>

posted on 2010-06-30 10:25  画一个圆圈  阅读(584)  评论(0)    收藏  举报

导航