• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: 小 中 大 | 推荐给好友 上一篇 | 下一篇

模拟qq的消息接收

发布: 2007-6-30 18:56 | 作者: admin | 来源: | 查看: 18次 | 进入软件测试论坛讨论

领测软件测试网     
接上:--->“模拟QQ的下拉列表选择图象(小白完善版)”
     我们知道,在使用qq时,当你的朋友给你发来消息时,他的头像会不停的闪动,直到你查看该条消息,他才安静下来。这次小白要做的就是模拟这个东东:
     1、来消息-->头像闪动
               首先我们取出用户列表---如果该用户没发新消息给你,则显示他注册时的头像,否则,显示的图片为我们特制的动画图片(也可以对他的图片进行js特效处理:过一定的时间显示,给人闪动的感觉),这里给出第一种方法的代码:
              <SCRIPT language=javascript>
var t

//在线会员
t=outlookbar.addtitle(‘’我的好友‘’)   
<%
dim x()
dim y()
dim news
dim thenews
dim i
dim j
news=false
i=0
set rs=server.CreateObject ("ADODB.RecordSet")
sqlstr="select * from msg where receiver=‘’"&session("icqusername")&"‘’ and state=‘’new‘’"
rs.Open sqlstr,conn,3,3
if not rs.BOF then
do while not rs.EOF
    redim Preserve x(i)
    redim Preserve y(i)
    x(i)=rs("sender")
    y(i)=rs("msgid")
    rs.MoveNext
    i=i+1
loop
end if
rs.Close
%>
//取出你在线的好友名单
//session("icqusername")为你自己
<%

sqlstr="select * from userinfor where username <> ‘’"&session("icqusername")&"‘’  and online=true  and ......."
‘’上面这条sql语句因你的程序而变
rs.open sqlstr,conn,1,1
do while not rs.eof
for j=0 to i-1
if rs("username")=x(j) then
    news=true
    thenews=y(j)
    exit for
end if
next
if news=true then

%>
//‘’如果有新消息
//jump.gif 为我特定给出的闪动的gif文件
//当点击该gig图片时,触发的事件为look_msg(....),详见下面的介绍
    outlookbar.additem("<img src=face/jump.gif border=0 alt=‘’查看消息‘’  style=‘’CURSOR: se-resize‘’ onClick=javascript:look_msg(‘’<%=thenews%>‘’,‘’<%=rs("username")%>‘’,this,‘’face/<%=rs("face")%>‘’)><br><%=rs("username")%>",t,"","")


<%
    news=false
else
%>
//如果没消息,则显示该用户资料里的头像
    outlookbar.additem("<img src=face/<%=rs("face")%> border=0 style=‘’cursor:hand‘’  alt=‘’双击发送消息‘’ ondblClick=javascript:openScript(‘’messanger.asp?touser=<%=rs("username")%>‘’,370,210)><br><%=rs("username")%>",t,"","")
<%
end if
rs.movenext
loop
rs.close
set rs=nothing
%>
  locatefold("我的好友")

</SCRIPT>

     2、查看消息后(当点击该闪动的图象查看消息),恢复用户图象为用户资料里的头像。
     这个函数比较简单,只要传递参数,改变当前的图象就行了:


<SCRIPT LANGUAGE=javascript>
<!--
function look_msg(thenews,touser,chg_img,img_url){
var url="messanger.asp?action="+thenews+"&touser="+touser
chg_img.src=img_url   //改变显示的gif图片为用户的图象

openScript(url,370,210)   //打开查看消息的对话框
}
//-->
</SCRIPT>
///////////////////////////////////////
:*)>:(

整个演示效果见:xxx.yyy.zzz/abcde/hjk/index.htm  
!^&&())(_)_+_**^^$$$$)))______((*&%^%_**(%%$#())^%$%%
###源贴:http://club.topdigi.com.cn/showAnnounce.asp?id=16511
############

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:[email protected] 电话:010-51297073

软件测试 | 领测国际 | ISTQB | ISTQB官网 | TMMi | TMMi认证 | 国际软件测试工程师认证 | 领测软件测试网