refresh.htm ========= <HTML> <HEAD> <title>在线QQ</title> <link rel="stylesheet" type="text/css" href="forum.css"> </HEAD> <BODY onload=online() scroll=no topmargin="0" leftmargin="0" style="background-color: #8482C6; color: #FFFFFF; border: 2 solid #FFFFFF; padding: 0"> <marquee><font color=black>如果关闭此窗口将失去在线QQ功能!</font></marquee> <!--嘿嘿!!这里引用了ZEE的转换代码,用于解决无法显示汉字的,本来还有一段的不过在俺用的时候,发现加上那一段就不行了,所以去掉了,有兴趣的朋友可以到精华区去找一下zee的文章 --> <script language="vbscript"> Function bytes2BSTR(vIn) 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"> var lengt=0; <!--消除右键功能--> function no(){ alert("不支持右键!"); self.event.returnValue=false; } <!--弹出QQ对话框,见后面--> function sqq(uid,id){ window.open("sqq.asp?id="+id+"&uid="+uid,"_blank","width=400,height=180"); } <!--关键的函数,用于显示在线的会员--> function online(){ var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp.open("post","online.asp",false); xmlhttp.send(); var xmldom=new ActiveXObject("Microsoft.XMLDOM"); xmldom.async=false; body=bytes2BSTR(xmlhttp.responseBody); xmldom.loadXML(body); if(xmldom.parseError.errorCode!=0){ window.open("refresh2.asp","_self");<!--为了防止有些用户不支持xml,所以用了一个备用的asp版的--> return } else{ var uid=xmldom.documentElement.selectNodes("uid"); var id=xmldom.documentElement.selectNodes("id"); var sex=xmldom.documentElement.selectNodes("sex"); var xx=""; lengt=uid.length; for(var i=0;i<lengt;i++){ var im=""; if(id(0).text!="k") im="<img src=../jy/face/1.gif width=12 height=12>"; xx=xx+im+"<font color=red onclick=sqq('"+uid(i).text+"','"+id(i).text+"') style='cursor:hand' title='"+sex(i).text+"'>"+uid(i).text+"</font><br>"; } disonline.innerHTML=xx; window.setTimeout("online()",3000); } }
</script> <!--这个"resfresh4.asp"是用于当有自己的信息时弹出QQ对话框用的--> <iframe src="refresh4.asp" width=0 height=2 marginwidth=0 marginheight=0 frameborder=0> </iframe>
<input type=button value=" 在线网友:" class=ddyinput2> <div id=disonline style="height:230;overflow: auto"></div><br> <!--这里用到了scriptlet技术,你也可以试一下,和include差不多--> <OBJECT data=i11.htm height=14 style="HEIGHT: 93px; WIDTH: 770px" type=text/x-scriptlet width=14 VIEWASTEXT></OBJECT>
</BODY> </HTML> 好了,第一部分就到这里了!!
用于处理xmlhttp请求的asp程序,看看时不是很简单啊!?? ===== <%on error resume next Response.ContentType="text/xml" if Request.ServerVariables("REQUEST_METHOD")="POST" then set req=Server.CreateObject("Microsoft.XMLDOM") req.async=false req.load(Request) set conn=server.CreateObject("adodb.connection") conn.Open "odbc","uid","password" sql="select uid,id,sex from uidinfo order by id desc" set rs=server.CreateObject("adodb.recordset") rs.Open sql,conn Response.Write "<?xml version=""1.0"" ?>" Response.Write "<mess>" if not rs.EOF then do while not rs.EOF Response.Write "<id>"&trim(rs("id"))&"</id><uid>"&trim(rs("uid"))&"</uid><sex>"&trim(rs("sex"))&"</sex>" rs.MoveNext loop else Response.Write "<id>k</id><uid></uid><sex></sex>" end if Response.Write "</mess>" if rs.State=1 then rs.Close set rs=nothing conn.Close set conn=nothing set req=nothing end if %>
|