您的位置:首页 > 理论基础 > 计算机网络

利用Microsoft.XMLHTTP定制页面无刷新自动检索提示信息

2006-10-26 08:59 459 查看
页面脚本:

var guid = "null";
function CheckMessage()
{
var obj = guid;
var nn = Math.floor( Math.random() * 2000000);
//显示信息页面
var url = "MessageInfo.aspx?time="+nn+"&code=";
if(obj != "null")
{
url = url + obj;
guid = "null";
OpenPasswordWin(url,300,500);
document.getElementById("divMessage").innerHTML = "";
}
}
//检查是否有新的消息
function YouHadNewMessage(){
var Had = false;
//空白执行检索页面
url = "CheckMessage.aspx";
var nn = Math.floor( Math.random() * 2000000);
url += "?time="+nn;
var httpRequest;
if (typeof XMLHttpRequest != 'undefined') {
httpRequest = new XMLHttpRequest();
}
else if (typeof ActiveXObject != 'undefined') {
httpRequest = new ActiveXObject('Microsoft.XMLHTTP');
}
if (httpRequest) {
httpRequest.open('GET', url, false);
httpRequest.send(null);
if(httpRequest.status == 200){
var textInfo = httpRequest.responseText;
if(textInfo != "null") Had = true;
}}
if(Had){

guid = textInfo;
document.getElementById("divMessage").innerHTML = "<a href='#' title='查看站内短信' onclick='CheckMessage()' id='ss7'><font color=white>-</font></a><bgsound src='/images/newMessage.wav' border='0'>";
}
else
{
document.getElementById("divMessage").innerHTML = "";
}
setTimeout("YouHadNewMessage()",300000);
}
setTimeout("YouHadNewMessage()",300000);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: