import java.applet.*
import java.awt.*
import java.io.*
import java.net.*
import java.awt.event.*
public class ChatClient extends Applet{
protected boolean loggedIn//登入状态
protected Frame cp//聊天室框架
protected static int PORTNUM=7777//缺省端口号7777
protected int port//实际端口号
protected Socket sock
protected BufferedReader is//用于从sock读取数据的BufferedReader
protected PrintWriter pw//用于向sock写入数据的PrintWriter
protected TextField tf//用于输入的TextField
protected TextArea ta//用于显示对话的TextArea
protected Button lib//登入按钮
protected Button lob//登出的按钮
final static String TITLE ="Chatroom applet>>>>>>>>>>>>>>>>>>>>>>>>"
protected String paintMessage//发表的消息
public ChatParameter Chat
public void init(){
paintMessage="正在生成聊天窗口"
repaint()
cp=new Frame(TITLE)
cp.setLayout(new BorderLayout())
String portNum=getParameter("port")//呢个参数勿太明
port=PORTNUM
if (portNum!=null) //书上是portNum==null,十分有问题
port=Integer.parseInt(portNum)
//CGI
ta=new TextArea(14,80)
ta.setEditable(false)//read only attribute
ta.setFont(new Font("Monospaced",Font.PLAIN,11))
cp.add(BorderLayout.NORTH,ta)
Panel p=new Panel()
Button b
//for login button
p.add(lib=new Button("Login"))
lib.setEnabled(true)
lib.requestFocus()
lib.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
login()
lib.setEnabled(false)
lob.setEnabled(true)
tf.requestFocus()//将键盘输入锁定再右边的文本框中
}
})
//for logout button
p.add(lob=new Button ("Logout"))
lob.setEnabled(false)
lob.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
logout()
lib.setEnabled(true)
lob.setEnabled(false)
lib.requestFocus()
}
})
p.add(new Label ("输入消息:"))
tf=new TextField(40)
tf.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
if(loggedIn){
//pw.println(Chat.CMD_BCAST+tf.getText())//Chat.CMD....是咩野来?
int j=tf.getText().indexOf(":")
if(j>0) pw.println(Chat.CMD_MESG+tf.getText())
else
pw.println(Chat.CMD_BCAST+tf.getText())
tf.setText("")//勿使用flush()?
}
}
})
p.add(tf)
cp.add(BorderLayout.SOUTH,p)
cp.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
//如果执行了setVisible或者dispose,关闭窗口
ChatClient.this.cp.setVisible(false)
ChatClient.this.cp.dispose()
logout()
}
})
cp.pack()//勿明白有咩用?
//将Frame cp放在中间
Dimension us=cp.getSize(),
them=Toolkit.getDefaultToolkit().getScreenSize()
int newX=(them.width-us.width)/2
int newY=(them.height-us.height)/2
cp.setLocation(newX,newY)
cp.setVisible(true)
paintMessage="Window should now be visible"
repaint()
}
//登录聊天室
public void login(){
if(loggedIn) return
try{
sock=new Socket(getCodeBase().getHost(),port)
is=new BufferedReader(new InputStreamReader(sock.getInputStream()))
pw=new PrintWriter(sock.getOutputStream(),true)
}catch(IOException e){
showStatus("Can't get socket: "+e)
cp.add(new Label("Can't get socket: "+e))
return}
//构造并且启动读入器,从服务器读取数据,输出到文本框中
//这里,长成一个线程来避免锁住资源(lockups)
new Thread (new Runnable(){
public void run(){
String line
try{
while(loggedIn &&((line=is.readLine())!=null))
ta.appendText(line+"\n")
}catch(IOException e){
showStatus("我的天啊,掉线了也!!!!")
return
}
}
}).start()
//假定登录(其实只是打印相关信息,并没有真正登录)
// pw.println(Chat.CMD_LOGIN+"AppletUser")
pw.println(Chat.CMD_LOGIN+"AppletUser")
loggedIn =true
}
//模仿退出的代码
public void logout(){
if(!loggedIn)
return
loggedIn=false
try{
if(sock!=null)
sock.close()
}catch(IOException ign){
// 异常处理哦
}
}
//没有设置stop的方法,即使从浏览器跳到另外一个网页的时候
//聊天程序还可以继续运行
public void paint(Graphics g){
Dimension d=getSize()
int h=d.height
int w=d.width
g.fillRect(0,0,w,2)
g.setColor(Color.black)
g.drawString(paintMessage,10,(h/2)-5)
}
}
聊天室服务器端
import java.net.*
import java.io.*
import java.util.*
public class ChatServer{
//聊天室管理员ID
protected final static String CHATMASTER_ID="ChatMaster"
//系统信息的分隔符
protected final static String SEP=": "
//服务器的Socket
protected ServerSocket servSock
//当前客户端列表
protected ArrayList clients
//调试标记
protected boolean DEBUG=false
public ChatParameter Chat
//主方法构造一个ChatServer,没有返回值
public static void main(String[] argv){
System.out.println("Chat server0.1 starting>>>>>>>>>>>>>>>>")
ChatServer w=new ChatServer()
w.runServer()
System.out.println("***ERROR*** Chat server0.1 quitting")
}
//构造和运行一个聊天服务
ChatServer(){
Chat=new ChatParameter()
clients=new ArrayList()
try{
servSock=new ServerSocket(7777)//实有问题拉,不过可能是他自己定义既一个class.
System.out.println("Chat Server0.1 listening on port:"+7777)
}catch(Exception e){
log("IO Exception in ChatServer.<init>")
System.exit(0)
}
}
public void runServer(){
try{
while(true){
Socket us=servSock.accept()
String hostName=us.getInetAddress().getHostName()
System.out.println("Accpeted from "+hostName)
//一个处理的线程
ChatHandler cl=new ChatHandler(us,hostName)
synchronized(clients){
clients.add(cl)
cl.start()
if(clients.size()==1)
cl.send(CHATMASTER_ID,"Welcome!You are the first one here")
else{
cl.send(CHATMASTER_ID,"Welcome!You are the latest of"+
clients.size()+" users.")
}
}
}
}catch(Exception e){
log("IO Exception in runServer:"+e)
System.exit(0)
}
}
protected void log(String s){
System.out.println(s)
}
//处理会话的内部的类
protected class ChatHandler extends Thread {
//客户端scoket
protected Socket clientSock
//读取socket的BufferedReader
protected BufferedReader is
//在socket 上发送信息行的PrintWriter
protected PrintWriter pw
//客户端出主机
protected String clientIP
//句柄
protected String login
public ChatHandler (Socket sock,String clnt)throws IOException {
clientSock=sock
clientIP=clnt
is=new BufferedReader(
new InputStreamReader(sock.getInputStream()))
pw=new PrintWriter (sock.getOutputStream(),true)
}
//每一个ChatHandler是一个线程,下面的是他的run()方法
//用于处理会话
public void run(){
String line
try{
while((line=is.readLine())!=null){
char c=line.charAt(0)//我顶你老母啊 ,果只Chat.CMD咩xx冇定义 扑啊///!!!
line=line.substring(1)
switch(c){
//case Chat.CMD_LOGIN:
case 'l':
if(!Chat.isValidLoginName(line)){
send(CHATMASTER_ID,"LOGIN"+line+"invalid")
log("LOGIN INVALID from:"+clientIP)
continue
}
login=line
broadcast(CHATMASTER_ID,login+" joins us,for a total of"+
clients.size()+" users")
break
// case Chat.CMD_MESG:
case 'm':
if(login==null){
send(CHATMASTER_ID,"please login first")
continue
}
int where =line.indexOf(Chat.SEPARATOR)
String recip=line.substring(0,where)
String mesg=line.substring (where+1)
log("MESG: "+login+"--->"+recip+": "+mesg)
ChatHandler cl=lookup(recip)
if(cl==null)
psend(CHATMASTER_ID,recip+"not logged in.")
else
cl.psend(login,mesg)
break
//case Chat.CMD_QUIT:
case 'q':
broadcast(CHATMASTER_ID,"Goodbye to "+login+"@"+clientIP)
close()
return//ChatHandler结束
// case Chat.CMD_BCAST:
case 'b':
if(login!=null)
broadcast(login,line)
else
log("B<L FROM"+clientIP)
break
default:
log("Unknow cmd"+c+"from"+login+"@"+clientIP)
}
}
}catch(IOException e){
log("IO Exception :"+e)
}finally{
//sock 结束,我们完成了
//还不能发送再见的消息
//得有简单的基于命令的协议才行
System.out.println(login+SEP+"All Done")
synchronized(clients){
clients.remove(this)
if(clients.size()==0){
System.out.println(CHATMASTER_ID+SEP+
"I'm so lonely I could cry>>>>>")
}else if(clients.size()==1){
ChatHandler last=(ChatHandler)clients.get(0)
last.send(CHATMASTER_ID,"Hey,you are talking to yourself again")
}
else{
broadcast(CHATMASTER_ID,"There are now"+clients.size()+" users")
}
}
}
}
protected void close(){
if(clientSock==null){
log("close when not open")
return
}
try{
clientSock.close()
clientSock=null
}catch(IOException e){
log("Failure during close to "+clientIP)
}
}
//发送一条消息给用户
public void send(String sender,String mesg){
pw.println(sender+SEP+"*>"+mesg)
}
//发送私有的消息
protected void psend(String sender ,String msg){
send("<*"+sender+"*>",msg)
}
//发送一条消息给所有的用户
public void broadcast (String sender,String mesg){
System.out.println("Broadcasting"+sender+SEP+mesg)
for(int i=0i<clients.size()i++){
ChatHandler sib=(ChatHandler)clients.get(i)
if(DEBUG)
System.out.println("Sending to"+sib)
sib.send(sender,mesg)
}
if(DEBUG) System.out.println("Done broadcast")
}
protected ChatHandler lookup(String nick){
synchronized(clients){
for(int i=0i<clients.size()i++){
ChatHandler cl=(ChatHandler)clients.get(i)
if(cl.login.equals(nick))
return cl
}
}
return null
}
//将ChatHandler对象转换成一个字符串
public String toString(){
return "ChatHandler["+login+"]"
}
}
}
public class ChatParameter {
public static final char CMD_BCAST='b'
public static final char CMD_LOGIN='l'
public static final char CMD_MESG='m'
public static final char CMD_QUIT='q'
public static final char SEPARATOR=':'//?????
public static final int PORTNUM=7777
public boolean isValidLoginName(String line){
if (line.equals("CHATMASTER_ID"))
return false
return true
}
public void main(String[] argv){
}
}
记得加分啊!!!
我以前也做过个简单的聊天室,后来因为另有任务没有做完,不过表情还是基本实现了,和你交流一下希望对你有点帮助。我的原理是这样的:因为我发言用的是文本框,而文本框不支持图片,所以只能用符号来代替,用户选择图片后保存的实际是该图片所对应的符号,显示时再判断一下发言内容是否包含那些符号。如果有的话则把该符号转换成所对应图片的路径就好了。图片可以到网上找,符号可以在msn里找到,在msn聊天窗口->选择图片->其他,可以看到图片对应的符号,如果你直接在msn里输入符号它自动会转换成图片,可是文本框不行。听说网上有个FreeTextBox好用,可我用不来。
在html里有个隐藏层(div)里面是一个表格存放表情
然后页面上有个表情图片点击可控制 层的显示和隐藏
用户点击某个表情后就得到了个符号。
下面的html代码主要是隐藏层的实现和符号的取得贴出来你参考一下。当然你也可以将全部表情放在页面上然后用"radio"或"checkBox"选这样可能更简单点,至于后台符号转换成图片,开发语言可能不同你自己研究一下吧
<%@ Page language="c#" Codebehind="frmSend.aspx.cs" AutoEventWireup="false" Inherits="ChatRoom.Page.frmSend" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>frmSend</title>
<script language="javascript">
function doSubmit()
{
var user=document.all("txtUser")
var objUser=document.all("txtObjUser")
if(user.value==objUser.value)
{
alert("ト嵂サトワム。ヤ�ヘラヤシコチトフ・")
objUser.value="all"
return false
}
if(document.all("cbChat").checked)
{
if(document.all("txtObjUser").value=="all" || document.all("txtObjUser").value=="All")
{
alert("ヒスチトカヤマ�サトワホェall")
return false
}
}
return true
}
ie4=(document.all)?true:false
ns4=(document.layers)?true:false
function toExit()
{
var args=toExit.arguments
var visible=args[0]
if(ns4)
{
theObj=eval("document.layers[\'"+args[1]+"\']")
if(theObj)theObj.visibility=visible
}
else if(ie4)
{
if(visible=='show')visible='visible'
if(visible=='hide')visible='hidden'
theObj=document.all("Layer1")
if(theObj)theObj.style.visibility=visible
}
}
function doClick(em)
{
var txt=document.all("txtMessage").value
txt+=em
document.all("txtMessage").value=txt
document.all("hidEmotion").value=em
toExit('hide','boysoft')
}
function doBold()
{
var word=document.all("txtMessage")
if (word.style.fontWeight == "bold")
{
word.style.fontWeight = "normal"
document.all("hidBold").value=""
}
else
{
word.style.fontWeight = "bold"
document.all("hidBold").value="bold"
}
event.cancelBubble = true
event.returnValue = false
}
function doItalic()
{
var txt=document.getElementById("txtMessage")
if(txt.style.fontStyle=="italic")
{
txt.style.fontStyle="normal"
document.all("hidItalic").value=""
}
else
{
txt.style.fontStyle="italic"
document.all("hidItalic").value="italic"
}
}
function doShowColor()
{
var args=doShowColor.arguments
var visible=args[0]
if(ns4)
{
theObj=eval("document.layers[\'"+args[1]+"\']")
if(theObj)theObj.visibility=visible
}
else if(ie4)
{
if(visible=='show')visible='visible'
if(visible=='hide')visible='hidden'
theObj=document.all("Layer3")
if(theObj)theObj.style.visibility=visible
}
}
function doHidde()
{
toExit('hide','boysoft')
doShowColor('hide','boysoft')
}
function doSetColor(id)
{
var txt=document.getElementById("txtMessage")
var imgColor=document.getElementById("imgColor")
txt.style.color=id
document.all("hidColor").value=id
imgColor.style.backgroundColor=id
doShowColor('hide','boysoft')
}
function doFontChange(txtFont)
{
if(txtFont=="Font")
{
return
}
document.getElementById("txtMessage").style.fontFamily=txtFont
document.all("hidFont").value=txtFont
}
function doSizeChang(txtSize)
{
if(txtSize=="Size")
{
return
}
document.getElementById("txtMessage").style.fontSize=txtSize
document.all("hidSize").value=txtSize
}
</script>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidthdocument.MM_pgH=innerHeightonresize=MM_reloadPage}}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload()
}
MM_reloadPage(true)
//-->
</script>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidthdocument.MM_pgH=innerHeightonresize=MM_reloadPage}}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload()
}
MM_reloadPage(true)
//-->
</script>
</HEAD>
<body onmousedown="doHidde()" bgColor="#edf1fa" onload="document.Form1.txtMessage.focus()"
MS_POSITIONING="GridLayout">
<form id="Form1" onsubmit="javascript:return doSubmit()" method="post" runat="server">
<INPUT id="hidBold" style="Z-INDEX: 103LEFT: 64pxWIDTH: 152pxPOSITION: absoluteTOP: 216pxHEIGHT: 22px"
type="hidden" size="20" name="hidBold"><INPUT id="hidEmotion" style="Z-INDEX: 109LEFT: 64pxPOSITION: absoluteTOP: 416px"
type="hidden" name="Hidden6" runat="server"><INPUT id="hidColor" style="Z-INDEX: 108LEFT: 64pxPOSITION: absoluteTOP: 448px" type="hidden"
name="Hidden7" runat="server"><INPUT id="hidFont" style="Z-INDEX: 107LEFT: 64pxPOSITION: absoluteTOP: 344px" type="hidden"
name="Hidden4" runat="server"><INPUT id="hidSize" style="Z-INDEX: 106LEFT: 64pxPOSITION: absoluteTOP: 376px" type="hidden"
name="Hidden5" runat="server"><INPUT id="hidUnderLine" style="Z-INDEX: 105LEFT: 64pxPOSITION: absoluteTOP: 304px"
type="hidden" name="Hidden3" runat="server"><INPUT id="hidItalic" style="Z-INDEX: 104LEFT: 64pxPOSITION: absoluteTOP: 256px"
type="hidden" name="Hidden2" runat="server">
<TABLE id="Table1" style="WIDTH: 712pxHEIGHT: 112px" cellSpacing="1" cellPadding="1"
width="712" border="1">
<TR>
<TD><span title="bold"><IMG onclick="doBold()" src="../images/bold.gif"> </SAPN><span title="italic" onclick="doItalic()"><IMG src="../images/italic.gif"></span><span title="underline" onclick="doUnderline()"><IMG src="../images/underline.gif"></span><span title="Font Color"><IMG id="imgColor" style="BACKGROUND-COLOR: black" onclick="doShowColor('show','boysoft')"
src="../images/colourpick.gif" runat="server"></span> <SELECT onchange="doFontChange(this.value)" name="ddFont" id="Select1" runat="server">
<OPTION value="Font" selected>Font</OPTION>
<OPTION value="Arial">Arial</OPTION>
<OPTION value="Verdana">Verdana</OPTION>
<OPTION value="Comic Sans MS">Comic Sans MS</OPTION>
<OPTION value="Courier">Courier</OPTION>
<OPTION value="Georgia">Georgia</OPTION>
<OPTION value="Impact">Impact</OPTION>
<OPTION value="Lucida Console">Lucida Console</OPTION>
<OPTION value="Tahoma">Tahoma</OPTION>
<OPTION value="Times New Roman">Times New Roman</OPTION>
<OPTION value="Wingdings">Wingdings</OPTION>
</SELECT><SELECT onchange="doSizeChang(this.value)" name="ddSize" id="Select2" runat="server">
<OPTION value="Size" selected>Size</OPTION>
<OPTION value="12px">12</OPTION>
<OPTION value="13px">13</OPTION>
<OPTION value="14px">14</OPTION>
<OPTION value="15px">15</OPTION>
<OPTION value="16px">16</OPTION>
<OPTION value="17px">17</OPTION>
<OPTION value="18px">18</OPTION>
<OPTION value="19px">19</OPTION>
<OPTION value="20px">20</OPTION>
<OPTION value="21px">21</OPTION>
<OPTION value="22px">22</OPTION>
<OPTION value="23px">23</OPTION>
<OPTION value="24px">24</OPTION>
<OPTION value="25px">25</OPTION>
<OPTION value="26px">26</OPTION>
<OPTION value="27px">27</OPTION>
<OPTION value="28px">28</OPTION>
<OPTION value="29px">29</OPTION>
<OPTION value="30px">30</OPTION>
<OPTION value="31px">31</OPTION>
<OPTION value="32px">32</OPTION>
</SELECT> <span title="insert emotions"><IMG onclick="toExit('show','boysoft')" src="../images/emotion.gif"></span> <span title="sign out">
<asp:imagebutton id="ibExit" runat="server" ImageUrl="../images/logoff.gif"></asp:imagebutton></span></span>
<div id="Layer1" style="BORDER-RIGHT: #000000 1pxBORDER-TOP: #000000 1pxZ-INDEX: 101LEFT: 286pxVISIBILITY: hiddenBORDER-LEFT: #000000 1pxWIDTH: 200pxBORDER-BOTTOM: #000000 1pxPOSITION: absoluteTOP: 48pxHEIGHT: 115px">
<table cellPadding="0" width="200" bgColor="#ffffff" border="1">
<tr>
<td><IMG onmouseup="doClick('(A)')" height="19" src="../images/emangel.gif" width="19" name="emangel"></td>
<td><IMG onmouseup="doClick(':@ (')" height="19" src="../images/emangry.gif" width="19" name="emangry"></td>
<td><IMG onmouseup="doClick('(B)')" height="19" src="../images/embeer.gif" width="19" name="embeer"></td>
<td><IMG onmouseup="doClick('(^)')" height="19" src="../images/emcake.gif" width="19"></td>
<td><IMG onmouseup="doClick('(@)')" height="19" src="../images/emcat.gif" width="19"></td>
<td><IMG onmouseup="doClick('(O)')" height="19" src="../images/emclock.gif" width="19"></td>
<td><IMG onmouseup="doClick('(D)')" height="19" src="../images/emcocktl.gif" width="19"></td>
<td><IMG onmouseup="doClick(':S')" height="19" src="../images/emcrook.gif" width="19"></td>
</tr>
<tr>
<td><IMG onmouseup="doClick(':。ョ(')" height="19" src="../images/emcry.gif" width="19"></td>
<td><IMG onmouseup="doClick(':|')" height="19" src="../images/emdgust.gif" width="19"></td>
<td><IMG onmouseup="doClick('(&)')" height="19" src="../images/emdog.gif" width="19"></td>
<td><IMG onmouseup="doClick(':$')" height="19" src="../images/emembarrassed.gif" width="19"></td>
<td><IMG onmouseup="doClick('(X)')" height="19" src="../images/emfemale.gif" width="19"></td>
<td><IMG onmouseup="doClick('(~)')" height="19" src="../images/emfilm.gif" width="19"></td>
<td><IMG onmouseup="doClick('(G)')" height="19" src="../images/emgift.gif" width="19"></td>
<td><IMG onmouseup="doClick('(})')" height="19" src="../images/emhug2.gif" width="19"></td>
</tr>
<tr>
<td><IMG onmouseup="doClick('({)')" height="19" src="../images/emhug.gif" width="19"></td>
<td><IMG onmouseup="doClick('(K)')" height="19" src="../images/emlips.gif" width="19"></td>
<td><IMG onmouseup="doClick('8-|')" height="19" src="../images/17.gif" width="19"></td>
<td><IMG onmouseup="doClick('(L)')" height="19" src="../images/emlove.gif" width="19"></td>
<td><IMG onmouseup="doClick('(Z)')" height="19" src="../images/emmale.gif" width="19"></td>
<td><IMG onmouseup="doClick('(M)')" height="19" src="../images/emmessag.gif" width="19"></td>
<td><IMG onmouseup="doClick('(S)')" height="19" src="../images/emmoon.gif" width="19"></td>
<td><IMG onmouseup="doClick('(8)')" height="19" src="../images/emnote.gif" width="19"></td>
</tr>
<tr>
<td><IMG onmouseup="doClick('(T)')" height="19" src="../images/emphone.gif" width="19"></td>
<td><IMG onmouseup="doClick('(P)')" height="19" src="../images/emphoto.gif" width="19"></td>
<td><IMG onmouseup="doClick('(F)')" height="19" src="../images/emrose.gif" width="19"></td>
<td><IMG onmouseup="doClick('(W)')" height="19" src="../images/emrosesad.gif" width="19"></td>
<td><IMG onmouseup="doClick(':(')" height="19" src="../images/emsad.gif" width="19"></td>
<td><IMG onmouseup="doClick(':)')" height="19" src="../images/emsmile.gif" width="19"></td>
<td><IMG onmouseup="doClick('(H)')" height="19" src="../images/emsmiled.gif" width="19"></td>
<td><IMG onmouseup="doClick(':-O')" height="19" src="../images/emsmileo.gif" width="19"></td>
</tr>
<tr>
<td><IMG onmouseup="doClick(':P')" height="19" src="../images/emsmilep.gif" width="19"></td>
<td><IMG onmouseup="doClick('(*)')" height="19" src="../images/emstar.gif" width="19"></td>
<td><IMG onmouseup="doClick('(C)')" height="19" src="../images/emtea.gif" width="19"></td>
<td><IMG onmouseup="doClick(':D')" height="19" src="../images/emteeth.gif" width="19"></td>
<td><IMG onmouseup="doClick('(N)')" height="19" src="../images/emthdown.gif" width="19"></td>
<td><IMG onmouseup="doClick('(Y)')" height="19" src="../images/emthup.gif" width="19"></td>
<td><IMG onmouseup="doClick('(U)')" height="19" src="../images/emunlove.gif" width="19"></td>
<td><IMG onmouseup="doClick(')')" height="19" src="../images/emwink.gif" width="19"></td>
</tr>
</table>
</div>
</TD><!--font style="FONT-WEIGHT: boldFONT-SIZE: 30pxCOLOR: redFONT-STYLE: italicFONT-FAMILY: 'Arial Black'TEXT-DECORATION: underline"--></TR>
<TR>
<TD style="HEIGHT: 53px"><asp:textbox id="txtMessage" ForeColor="" runat="server" Width="576px" Height="43px"></asp:textbox><asp:button id="btSay" runat="server" Height="42px" Text="send"></asp:button></TD>
</TR>
<TR>
<TD><asp:textbox id="txtUser" runat="server" Width="120px" ReadOnly="True" BorderStyle="Groove" BackColor="#EDF1FA"
ForeColor="Black"></asp:textbox><asp:label id="Label2" runat="server">to</asp:label><FONT face="ヒホフ・><FONT face="ヒホフ・><asp:textbox id="txtObjUser" runat="server" Width="120px" ReadOnly="True" BorderStyle="Groove"
BackColor="#EDF1FA"></asp:textbox></FONT></FONT><FONT face="ヒホフ・></FONT><asp:checkbox id="cbChat" runat="server" Text="Whisper "></asp:checkbox></TD>
</TR>
</TABLE>
</form>
<div id="Layer3" style="Z-INDEX: 102LEFT: 87pxVISIBILITY: hiddenWIDTH: 115pxPOSITION: absoluteTOP: 49pxHEIGHT: 73px">
<table borderColor="#c0c0c0" height="60" cellPadding="0" width="114" border="1">
<tr>
<td onmousedown="doSetColor('#FF0000')" width="12" bgColor="#ff0000"> </td>
<td onmousedown="doSetColor('#00ff00')" width="12" bgColor="#00ff00"> </td>
<td onmousedown="doSetColor('#0000ff')" width="12" bgColor="#0000ff"> </td>
<td onmousedown="doSetColor('#ffff00')" width="12" bgColor="#ffff00"> </td>
<td onmousedown="doSetColor('#00ffff')" width="12" bgColor="#00ffff"> </td>
<td onmousedown="doSetColor('#ff00ff')" width="14" bgColor="#ff00ff"> </td>
<td onmousedown="doSetColor('#000000')" width="10" bgColor="#000000"> </td>
</tr>
<tr>
<td onmousedown="doSetColor('#ff8040')" bgColor="#ff8040"> </td>
<td onmousedown="doSetColor('#0080ff')" bgColor="#0080ff"> </td>
<td onmousedown="doSetColor('#408080')" bgColor="#408080"> </td>
<td onmousedown="doSetColor('#c0c0c0')" bgColor="#c0c0c0"> </td>
<td onmousedown="doSetColor('#0000a0')" bgColor="#0000a0"> </td>
<td onmousedown="doSetColor('#8000ff')" bgColor="#8000ff"> </td>
<td onmousedown="doSetColor('#ff80ff')" bgColor="#ff80ff"> </td>
</tr>
<tr>
<td onmousedown="doSetColor('#8080c0')" bgColor="#8080c0"> </td>
<td onmousedown="doSetColor('#008040')" bgColor="#008040"> </td>
<td onmousedown="doSetColor('#808040')" bgColor="#808040"> </td>
<td onmousedown="doSetColor('#99cc33')" bgColor="#99cc33"> </td>
<td onmousedown="doSetColor('#00ff80')" bgColor="#00ff80"> </td>
<td onmousedown="doSetColor('#ff3399')" bgColor="#ff3399"> </td>
<td onmousedown="doSetColor('#ff8080')" bgColor="#ff8080"> </td>
</tr>
</table>
</div>
</body>
</HTML>
你这个是什么程序,ichat吗?给你个参考!<HTML>
<head><META content="聊天,语音,语聊,可视,视频,嘉宾,访谈,深圳东方博雅科技,ICHAT,CHAT,VIDEO,AUDIO" name=Keywords><META content="iChat聊天--可视语音嘉宾聊天" name=Description>
<TITLE>用户列表</TITLE>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">
<style type="text/css">
<!--
body {
font-family: "宋体"
font-size: 9pt
line-height: 12pt
margin-left: 0px
}
select { BACKGROUND-COLOR: #efefefCOLOR: blackFONT-FAMILY: 宋体FONT-SIZE: 9ptBorder-width: 1px}
a:visited { text-decoration: none}
a:link { text-decoration: none}
a:hover {
text-decoration: none
}
.boy { color: 0000FF}
.girl { color: FF80FF}
.private { color: green}
.offline { color: gray}
.p9 {font-size: 9pt}
.p11{font-size: 11pt}
body,td,th {
font-family: 宋体
}
a:active {
text-decoration: none
}
.STYLE1 {
font-size: 20pt
color: #FFFF00
}
-->
</style>
<script language="JavaScript">
var strFormat = "<!--$ICON_FORMAT-->"
var strMembersTag = "<!--$MEMBERS_TAG-->"
var nMembersDisp = <!--$MEMBERS_DISPLAY-->
function ShowTips(strUser,pThis)
{
var obj = parent.Users.FindObject(strUser)
if(obj == null) return
var xb, cs, level
if(obj.XB == 0)
{
xb = "女士"
cs = "girl"
}else
{
if(obj.XB == 1)
{
xb = "男士"
cs = "boy"
}else
{
xb = "不详"
cs = "private"
}
}
if(obj.Level <10)
level = obj.Level + " "
else
level = obj.Level
var s = "<table width=130 border=0 cellspacing=1 cellpadding=2 bgcolor=#000066><tr bgcolor="
if(obj.Online == 0) s += "#ffffe7"
else s += "#dedfdf"
s += "><td><center><table border=0 class='p9'><tr height=40 align=center><td>"
if(obj.Icon.length >0)
s += strFormat.replace("<!--$OBJECT-->", obj.Icon)
else
s += "<font face=Wingdings size=7 color=#FF0000>J</font>"
s += "</td><td valign=bottom><span class='p11'><font color=#FF9900><B>"
s += parent.GetTitle(obj.Level) + "</B></font></span><BR>"
if(parent.Users.FindObject(parent.youself).Level >= level)
s += "级别:<font color=red>" + level + "级</font><BR>"
else
s += "<BR>"
s += "性别:" + "<span class='" + cs + "'>" + xb + "</span>"
s += "</td></tr><tr><td>姓名:</td><td class='" + cs + "'>" + obj.UserName
s += "</td></tr><tr><td>昵称:</td><td class='" + cs + "'>" + obj.NickName
if(obj.Arming.length >0)
{
s += "</td></tr><tr><td colspan=2 align=center>"
s += strFormat.replace("<!--$OBJECT-->", obj.Arming)
}
s += "</td></tr><tr><td colspan=2 align=center>"
if(obj.Admin == 2)
s += "<font color=red>★ ★管 理 员★ ★</font>" // 正式管理员
else
if(obj.Admin == 1)
s += "<font color=red>☆ ☆临 管 员☆ ☆</font>" // 临时管理员
s += "</td></tr></center></table></td></tr></table>"
Tips.innerHTML = s
var pTip = document.all["Tips"].style
pTip.left = getPos(pThis,"left") - 9
pTip.top = pThis.offsetHeight + getPos(pThis,"top")
pTip.width = 130
pTip.display = ""
if(Tips.offsetTop + Tips.offsetHeight >document.body.offsetHeight)
pTip.top = getPos(pThis,"top") - Tips.offsetHeight
}
function getPos(obj,type)
{
var n = 0
while(obj!=null)
{ if(type=="top")
n += obj.offsetTop
else
n += obj.offsetLeft
obj = obj.offsetParent
}
return n
}
function Hidden()
{
var obj = document.all["Tips"].style
obj.left = 0
obj.top = 0
obj.display = "none"
}
function GetComment(obj,type)
{
var xb, state
if(obj.XB == 0) xb = "女士" else{if(obj.XB == 1) xb = "男士" else xb = "不详" }
if(obj.Online == 0) state = "聊天中…" else state = "暂时离开"
var s = ""
var strComment = "\t\t\t\t\t\r\n"
if(type == null) strComment = " **用户资料**\r\n"
else s = type
strComment += s + "姓名:" + obj.UserName + "\r\n"
strComment += s + "昵称:" + obj.NickName + "\r\n"
strComment += s + "性别:" + xb + "\r\n"
strComment += s + "状态:" + state + "\r\n"
strComment += s + "级别:" + obj.Level + "\r\n"
strComment += s + "头衔:" + parent.GetTitle(obj.Level)
return strComment
}
function DoWhois(str)
{ var obj = parent.Users.FindObject(str)
if(obj == null) return
parent.whois(obj.UserName)
}
function RndUsers()
{ var r, obj , n = parent.Users.GetCount()
if(n >5)
{ for(var i = 0i <5 i ++)
{ r = Math.round(Math.random()*(n-1))
obj = parent.Users.GetObject(r)
if(obj.UserName != parent.youself) break
}
if(i <5)
{ if(confirm(GetComment(obj,"\t") + "\r\n\r\n" + "系统推荐[ " + obj.NickName + " ]和您聊天,您愿意吗?"))
parent.cs(obj.UserName)
return
}
}
alert("非常抱歉,没有合适的聊友向您推荐!")
}
function OnSort(n)
{
switch(n)
{ case 0:
return
case "1":
parent.Users.SortByXB()
break
case "2":
parent.Users.SortByLevel()
break
case "3":
parent.Users.SortByName()
break
case "4":
parent.Users.SortByState()
break
case "90":
parent.ToMusic()
return
case "100":
parent.Loop(0)
break
case "101":
var loop = prompt("请设定音乐播放的次数,1至99为有效值,-1表示不限次数!",parent.MyMusic.Loop)
if(loop != null &&loop <100) parent.Loop(loop)
break
default:
parent.Play2(n)
break
}
if(n <10) parent.start()
else document.userlist.SELECT1.value = "0"
}
</script>
</HEAD>
<BODY rightmargin=0 onkeydown="if(event.keyCode==27)return false" oncontextmenu="return false">
<script>this.document.bgColor=parent.skin.UserColor</script>
<div id="Tips" style="position:absoluteleft:0top:0width:130display=none"></div>
<form action="/" name="userlist">
<table width="100%" border="2" align="left"><tr>
<th background="http://139007.com/bg8.gif" scope="row"><a href="http://139007.com/phpbbs" target="_blank" class="STYLE1">荆松聊吧</a></th>
</tr><tr>
<th background="http://139007.com/3/top2_bg.gif" scope="row"><a href="http://139007.com/phpbbs" target="_blank"><img src="http://139007.com/3/js.gif" width="120" height="30" border="0"></a></th>
</tr><tr>
<th background="http://139007.com/3/top2_bg.gif" scope="row"><a href="http://139007.com/dz" target="_blank"><img src="http://139007.com/3/ly.gif" width="120" height="30" border="0"></a></th>
</tr>
</table>
<div align="center"><br>
<br>
<br>
<br>
<br><br><br><br><br>
<script>
document.write("你自己:")
me=parent.youself
objs = parent.Users.FindObject(me)
document.write("<font color=red>")
document.write(objs.UserName)
document.write(" </font>")
</script>
<BR>
[<A href="javascript:parent.start()">刷新</A>|<A href="javascript:parent.ToMusic()"><font color=red>在线点歌台</font></A>]
<BR>
<SELECT name="SELECT1" onChange="OnSort(this.value)">
<OPTION value='0'>==显示顺序==</OPTION>
<OPTION value='1'>按女士优先</OPTION>
<OPTION value='2'>按级别高低</OPTION>
<OPTION value='3'>按姓名长度</OPTION>
<OPTION value='4'>按在线状态</OPTION>
<OPTION value='90' style="BACKGROUND:redCOLOR:white">*在线点歌台*</OPTION>
<OPTION value="100">停止播放音乐</OPTION>
<OPTION value="101">设定播放次数</OPTION>
</SELECT></div><br><div align="left">
[在线用户:<font color=red><B>
<script>document.write(parent.Users.GetCount())</script>
</B></font>人]
<hr>
<div align="left">[<A href="javascript:parent.FindFriend()"><font color=red>查寻聊友</font></A>/<A href="javascript:RndUsers()"><font color=red>自动推荐</font></A>]<br>
[<A href="http://139007.com/kj/xc/" title="本功能需要泡到一定级别才能正常使用!欢迎大家泡分体验!" target="_blank"><font color=red>香港本港台</font></A>]<img src=http://image.ichat.net.cn/voiceimage/video.gif><br><script language="JavaScript">
var color//性别的颜色区分,修改性别区分颜色请编辑CSS属性的 .boy .girl .private
var obj, UserName, NickName, XB, ICON
for(var i=0i<parent.Users.GetCount()i ++)//循环写用户列表
{
obj = parent.Users.GetObject(i)
if(obj.NickName.length >0)
{
UserName = obj.UserName // 姓名
Nick = obj.NickName // 昵称
XB = obj.XB // 性别
ICON = obj.Icon// 头像
if(obj.Online == 0)
{ if(XB == 0)
color="girl"
else
if(XB ==1) //判断性别,然后用不同颜色表示
color="boy"
else color="private"
}else
color="offline"
document.write("[<A href=\"javascript:parent.cs('"+UserName+"')\" onmouseover=\"ShowTips('" + UserName + "'," + "this" + ")\" onmouseout=\"Hidden()\"")
document.write(" ondblclick='DoWhois(\"" + obj.UserName + "\")'>")
document.write("<span class='"+color+"'>")
if(obj.Admin == 2) document.write("<font color=#FF0000>★</font>") // 正式管理员
else
if(obj.Admin == 1) document.write("<font color=#FF0000>☆</font>")// 临时管理员
document.write(Nick+"</span></A>]")
if(UserName==parent.youself) document.write("<font color=red><=</font>")//你自己
document.write("<BR>")
}
}
/* 注:变量 parent.MaxOnline 代表本房间历史最高在线人数 */
</script></div><hr>
<INPUT type="checkbox" name="ch1" onClick="parent.bTimer=this.checked" onDblClick="parent.bTimer=this.checked"><A href="javascript:userlist.ch1.click()">定时刷新名单</a>
<BR><BR>
<table width="100%" border="1" bgcolor="#FFFFFF">
<tr>
<th align="center" valign="top" bordercolor="" background="http://139007.com/3/top2_bg.gif" bgcolor="" scope="row"><a href="http://www.ltb888.com/1/" target="_blank"><img src="http://139007.com/3/gy.gif" width="120" height="30" border="0"></a></th>
</tr>
<tr>
<th align="center" valign="top" bordercolor="" background="http://139007.com/3/top2_bg.gif" bgcolor="" scope="row"><a href="http://139007.com/dj.htm" target="_blank"><img src="http://139007.com/3/yy.gif" width="120" height="30" border="0"></a></th>
</tr>
<tr>
<th align="center" valign="top" bordercolor="" background="http://139007.com/3/top2_bg.gif" bgcolor="" scope="row"><a href="http://www.nfd.com.tw/house/1976-99.htm" target="_blank" class="STYLE24"><img src="http://139007.com/3/ls.gif" width="120" height="30" border="0"></a></th>
</tr>
<tr>
<th align="center" valign="top" bordercolor="" background="http://139007.com/3/top2_bg.gif" bgcolor="" scope="row"><a href="http://www.dffy.com/iq/index.asp?pageid=33" target="_blank" class="STYLE24"><img src="http://139007.com/3/zw.gif" width="120" height="30" border="0"></a></th>
</tr>
<tr>
<th align="center" valign="top" bordercolor="" background="http://139007.com/3/top2_bg.gif" bgcolor="" scope="row"><a href="http://code.51boba.com" target="_blank"><img src="http://139007.com/3/wl.gif" width="120" height="30" border="0"></a></th>
</tr>
<tr>
<th height="39" align="center" valign="top" bordercolor="" background="http://139007.com/3/top2_bg.gif" bgcolor="" scope="row"><a href="http://www.singaporepools.com.sg/Lottery?page=toto" target="_blank"><img src="http://139007.com/3/xjp.gif" width="120" height="30" border="0"></a></th>
</tr>
<tr>
<th align="center" valign="top" bordercolor="" background="http://139007.com/3/top2_bg.gif" bgcolor="" scope="row"><a href="http://139007.com:8889/UserGuide" target="_blank"><img src="http://139007.com/3/dj.gif" width="120" height="30" border="0"></a></th>
</tr>
<tr>
<th align="center" valign="top" bordercolor="" background="http://139007.com/3/top2_bg.gif" bgcolor="" scope="row"><a href="http://www.ip138.com/" target="_blank"><img src="http://139007.com/3/ip.gif" width="120" height="30" border="0" class="girl"></a></th>
</tr>
</table>
</a></DIV>
<script>userlist.ch1.checked=parent.bTimer</script>
</form>
</BODY>
</HTML>