主程序:
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Description" content="">
</head>
<script language="JavaScript" src="Noname3.js">
</script>
<body onLoad="init();">
<form method=post action='' name='form1'>
gid:<input type="text" name="gid" value="">
<input type='button' name='Start' onclick='if(form1.gid.value=="")form1.gid.value=gid;flag=true;Start.disabled=true;Pause.disabled=false;GetResult(document.all.gid.value)' value='Start'>
<input type='button' name='Pause' onclick='javascript:flag=false;Pause.disabled=true;Start.disabled=false;' value='Pause' Disabled=true>
<br>
<!-- 两个span用户调试 -->
<span id='result1'></span><br>
<span id='result2'></span>
<select name='result3' MULTIPLE style='width:950;height:400;font-size:20' onChange='select_one();'></select><br>
<textarea type='text' name='selected' style='width:950;height:100;font-size:25;font-weight:bold ' ReadOnly></textarea>
</form>
</body>
</html>
Noname3.js:
var CookieString = document.cookie;
var flag = true;//用户控制开始暂停标记
var gid = CookieString.substr(4,CookieString.indexOf(";")-4);
if (CookieString.indexOf("gid=")==-1){
gid = 0;
}
function init()
{
form1.gid.value = gid;
}
function GetResult(str)
{
var oBao = new ActiveXObject("Microsoft.XMLHTTP");
//特殊字符:+,%,&,=,?等的传输解决办法.字符串先用escape编码的.
oBao.open("POST","http://www1.mocoto.com/custom/qddst/getbyid.aspx?gid="+escape(str),false);
oBao.send();
//服务器端处理返回的是经过escape编码的字符串.
//document.all.username.value=unescape(oBao.responseText)
gid=document.all.gid.value;
if (oBao.responseText!=" || || || "){//结束条件" || || || ",表示目前没有更新的数据
var str = oBao.responseText
var gid = str.substr(0,str.indexOf("||"))
var mobile=str.substr(str.indexOf("||")+2,str.indexOf("||",11)-str.indexOf("||")-2)
var begin = str.indexOf("||",11)+2
var content = str.substr(begin,str.indexOf("||",begin)-begin)
document.all.gid.value=gid;
//document.all.result1.innerHTML=mobile;
//document.all.result2.innerHTML=content;
form1.result3.options.add(new Option(mobile+":"+content), 0);
document.cookie = "gid="+gid;
if (flag)
window.setTimeout("GetResult(" + gid + ")", 1000);
}
else
if (flag)
window.setTimeout("GetResult(" + gid + ")", 10000);
}
function select_one()
{
//form1.selected.value = form1.result3.options[form1.result3.selectedIndex].text;
for(var i=0;i<form1.result3.length;i++){
if(form1.result3.options[i].selected){
form1.selected.value = form1.result3.options[i].text;
form1.result3.options[i].style.color="red";
var txt = form1.selected.value;
if (txt>"1"){//手机
txt = txt.substr(0,3)+"xxxx"+txt.substr(7);
}
else{
txt = txt.substr(0,4)+"xxxx"+txt.substr(8);
}
form1.selected.value = txt;
break;
}
}
}
正文
无刷新,更新页面内容2005-05-20 09:02:00
【评论】 【打印】 【字体:大 中 小】 本文链接:http://blog.pfan.cn/yang/1161.html
阅读(770) | 评论(0)
版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!
评论