|
楼主 |
发表于 2012-10-22 15:02:00
|
显示全部楼层
本帖最后由 fanxiang_1984 于 2012-10-22 15:25 编辑
回复 2# 小凯
就是类似进入网页版三国杀时,他需要下载一些信息,我怎么能随时记录这个下载信息。
网页版三国杀网址:http://web.sanguosha.com/
下面是我的源码。
<html>
<head>
<META http-equiv="pragma" content="no-cache" />
<META http-equiv="Content-Language" content="zh-cn">
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<LINK href="styleregister.css" type="text/css" rel="stylesheet">
<title>123</title>
<style type="text/css">
#information{font: 10pt "Arial"; color: #008080}
</style>
</head>
<body>
<TABLE cellSpacing=0 cellPadding=0 width=808 align=center border=0>
<TR>
<TD ><IMG height=137 src="../images/register_banner.gif" width=808></TD>
</TR>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 align=middle width=808 border=0>
<TR>
<TD width=77 background="../images/bg.gif" rowSpan=3></TD>
<TD align=center width=653 height=323 background="../images/register_content.gif">
<TABLE cellSpacing=0 cellPadding=0 width=96% height=15% border=0>
<TR>
<TD align=right><A href="../cgi-bin/login.htm.cgi"><FONT size=2 color=#000000>返回登录</FONT></A></TD>
</TR>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=400 border=0 height=80% align = center>
<TR>
<TD colSpan=2 height=32 id="note"></TD>
</TR>
<TR align>
<TD colSpan=2 width=100% height=10 align=center>
<div id="progress" align=left></div>
</TD>
</TR>
<TR>
<TD align=center colSpan=2 width=100% height=20 id="information">正在登陆,请稍后...</TD>
</TR>
<TR>
<TD align=center colSpan=2 width=100% height=20><font size=2>客服热线:100</font></TD>
</TR>
<TR>
<TD align=left colSpan=2 height=60></TD>
</TR>
</TABLE>
</TD>
<TD width=78 background="../images/bg.gif" rowSpan=3></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<script type="text/javascript" language="javascript">
<!--
var start = '0';
var bar;
var res;
var count = 0;
var result_flag = 0;
var result_count = 0;
function CProgress(progressIdStr, width, height, pos)
{
this.progressIdStr = progressIdStr;
this.progressId = document.getElementById(this.progressIdStr);
this.barIdStr = progressIdStr + "_bar";
this.barId = null;
this.pos = pos>=100?100:pos;
this.step = 1;
this.rate = 10;
this.limit = 10;
this.result = "正在登陆,请等待...";
this.progressWidth = width;
this.progressHeight = height;
this.Create = Create;
this.SetStep = SetStep;
this.SetPos = SetPos;
this.SetResult = SetResult;
this.SetRate = SetRate;
this.SetLimit = SetLimit;
this.Inc = Inc;
this.Desc = Desc;
}
function Create()
{
if (document.all)
{
this.progressId.style.width = this.progressWidth+2;
}
else
{
this.progressId.style.width = this.progressWidth;
}
this.progressId.style.height = this.progressHeight;
this.progressId.style.fontSize = this.progressHeight;
this.progressId.style.border = "1px solid #000000";
this.progressId.innerHTML = "<div id=\"" + this.barIdStr + "\" style=\"background-color:#aabbcc;height:100%;text-align:center\"></div>";
this.barId = document.getElementById(this.barIdStr);
this.SetPos(this.pos);
}
function SetStep(step)
{
this.step = step;
}
function SetPos(pos)
{
this.pos = (pos<=0)?0:pos;
this.pos = (parseInt(this.pos) >parseInt(this.limit))?this.limit:this.pos;
if(this.rate < 0)
this.pos = 100;
showResult();
}
function Inc()
{
count++;
this.pos = parseInt(this.pos) + parseInt(this.step);
this.SetPos(this.pos);
}
function Desc()
{
this.pos -= this.step;
this.SetPos(this.pos);
}
function SetLimit(limit){
this.limit = limit<0?0:limit;
this.limit = this.limit>100?100:this.limit;
}
function SetRate(rate){
this.rate = rate;
if(parseInt(rate) > parseInt(this.pos)){
this.SetLimit(parseInt(rate));
}
}
function SetResult(result){
this.result = result;
}
function showResult(){
if(count > 180) {
progress.barId.style.width = "100%";
document.getElementById("information").innerHTML="<a href=\"/register.html\">登陆超时!请检查后重试</a>";
}else{
progress.barId.style.width = progress.pos+"%";
if(parseInt(progress.rate)!=100 || parseInt(progress.pos)==100)
document.getElementById("information").innerHTML = progress.result;
}
progress.barId.innerHTML=progress.barId.style.width;
if(progress.barId.style.width == "100%"){
window.clearInterval(bar);
window.clearInterval(res);
return;
}
}
// create an XMLHttpClient in a cross-browser manner
function initXMLHttpClient(){
var xmlhttp;
if (window.ActiveXObject)
{
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
else
{
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function send_request(){
request.open('GET','register_res.html.cgi?num='+new Date().getTime(), true); // open asynchronus request
request.onreadystatechange = request_handler; // set request handler
request.send(null); // send request
}
function request_handler(){
if (request.readyState == 4){ // if state = 4 (the operation is completed)
if (request.status == 200 || request.status == 0){ // and the HTTP status is OK
// get progress from the XML node and set progress bar width and innerHTML
var array = request.responseText.split(";");
if(array[0] == -2){
alert('登陆失败,请输入正确的ID密码');
window.location='../register.html';
}
if( array[2] >= 32 ){
if(array[0]<20){
alert('登陆超时,请检查线路并输入正确的ID密码');
window.location='../register.html';
}else{
alert('业务下发失败,请检查管理配置');
window.location='../index.html';
}
}else if( array[2] < 5 ){
count=0;
}
progress.SetRate(array[0]);
progress.SetResult(array[1]);
result_flag = 1;
//result_count += 1;
//document.getElementById("note").innerHTML=array[0]+";"+array[1]+";"+array[2]+";"+count+";" + result_count;
}
else{ // if request status is different then 200
progress.style.width = '100%';
progress.innerHTML='Error: ['+request.status+'] '+request.statusText;
}
}
}
function checkresult(){
if(result_flag == 1){
result_flag = 0;
send_request();
}
}
var request = initXMLHttpClient();
var progress = new CProgress("progress", 300, 15, 0);
progress.Create();
if(start == 0){
send_request();
bar = setInterval("progress.Inc();",400);
res = setInterval("checkresult();",2000);
}else if(start == 2){
document.getElementById("information").innerHTML="登陆次数已超过最大重试次数<br>请联系100";
}else{
document.getElementById("information").innerHTML="程序内部错误";
}
//-->
</script>
</body>
</html> |
|