|
导读接上:--->“模拟QQ的下拉列表选择图象(小白完善版)” 我们知道,在使用qq时,当你的朋友给你发来消息时,他的头像会不停的闪动,直到你查看该条消息,他才安静下来。这次小白要做的就是模拟这个... 接上:--->“模拟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=trueand ......." '上面这条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=http://cfan.net.cn/info/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 ############ |
温馨提示:喜欢本站的话,请收藏一下本站!