<script language="vbscript">
Function bytes2BSTR(vIn)
Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
</script>
<script language="javascript">
function tocheck(obj)
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST","tocheck.asp?loginid="+obj.value, false);
xmlhttp.send();
var result
result= bytes2bstr(xmlhttp.responseBody)
alert(result);
xmlhttp = null;}
</script>
Function bytes2BSTR(vIn)
Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
</script>
<script language="javascript">
function tocheck(obj)
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST","tocheck.asp?loginid="+obj.value, false);
xmlhttp.send();
var result
result= bytes2bstr(xmlhttp.responseBody)
alert(result);
xmlhttp = null;}
</script>
下面框架页面(bottom.asp)主要就显示:你有新消息,新邮件,系统消息等等
-----------------
<script>
function MessageDetect(userid)
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET","background.asp?u=" + userid,false);
xmlhttp.send();
if (xmlhttp.status == "200")
if (xmlhttp.responseText == "1")
alert('你有新的消息');
xmlhttp = null;
delete xmlhttp;
}
setInterval(MessageDetect('<%=current_user%>'),5000);
</script>
------------
background.asp<%
Dim rs
response.contenttype = "text/xml"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "select count(1) from messages where userid='" & Request.QueryString("userid") & "' and isnew = 1",ActiveDBConnection,1,1,1
if rs(0) > 0 then
response.write "1"
else
response.wirte "0"
end if
rs.close
set rs = nothing
%>