87,901
社区成员
发帖
与我相关
我的任务
分享
<html>
<html>
<head>
<title>-- Chat --</title>
<SCRIPT type="text/javascript" src="jquery-1.4.2.js">
</SCRIPT>
</head>
<body>
<h3>Chat Frame</h3>
<div style="width: 950px;">
<hr />
<table width="100%">
<tr>
<td width="15%">
<table width="100%" align="center">
<tr><td width="100%"><div id="departments">
<a href="#" onclick="showStaffList('department3')"><h2>department3</h2></a>
<div style="display:none" id="department3">
<a href="#" id="staff9" ondblclick="showChatWindow('staff9')">Benjamin</a>
<br>
<a href="#" id="staff10" ondblclick="showChatWindow('staff10')">Barton</a>
<br>
<a href="#" id="staff11" ondblclick="showChatWindow('staff11')">Bartholomew</a>
<br>
<a href="#" id="staff12" ondblclick="showChatWindow('staff12')">Blithe</a>
</div>
</div></td></tr>
</table>
</td>
<td width="85%" background="images8.jpg">
<DIV id="condiv" style="width: 800px">
</DIV>
</td>
</tr>
</table>
<hr />
<div style="width: 100%" id="chatWindows"><h1>there is chat window</h1></div>
</body>
<script type="text/javascript">
function showStaffList(id){
var obj = $("#"+id);
if(obj.css("display")=="none"){
obj.css('display','block');
}else{
obj.css("display","none");
}
}
function showChatWindow(id){
var windowId = "#"+id+'window';
var obj = $(windowId);
if(obj.length>0){
if(obj.css("style")=="none"){
obj.css("style","block");
}else{
alert("chat window was opened");
}
}else{
createChatInterfase(id);
}
}
function createChatInterfase(id){
var windowId = id+'window';
var histroyId = id+'history';
var contentId = id+'content';
var windowDiv = $("#chatWindows");
var newDIV = $("<div>");
newDIV.attr("id",windowId);
newDIV.css({width: "305px","background-color": "#ccee99"});
var subDIV = $("<div>");
subDIV.attr("id",histroyId);
subDIV.css({width: "300px",height:" 220px","background-color":"#eeeedd"});
var text = $("<textarea>");
text.attr({cols:"26",rows:"2",id:contentId});
var closeButton = $("<input>");
closeButton.attr({type:"button",value:"close"});
closeButton.bind("click",{windowId:windowId},hideChatWindow);
var sendButton = $("<input>");
sendButton.attr({type:"button",value:"send"});
newDIV.append(subDIV);
newDIV.append(text);
newDIV.append(closeButton);
newDIV.append(sendButton);
windowDiv.append(newDIV);
}
function hideChatWindow(event){
var windowId = event.data.windowId;
alert("window id: " + windowId);
var obj = document.getElementById(windowId);
obj.style.display="none";
//var obj = $("#"+windowId);
//obj.css("display","none");
}
</script>
</html>
function hideChatWindow(event){
var windowId = event.data.windowId;
alert("window id: " + windowId);
var obj = document.getElementById(windowId);
obj.style.display="none";
//var obj = $("#"+windowId);
//obj.css("display","none");
}
function hideChatWindow(event){
windowId = event.data.windowId;
alert(windowId+"你大爷的!!");
var obj = document.getElementById(windowId);
obj.style.display="none";
//var obj = $("#"+windowId);
//obj.css("display","none");
}