日期:2014-05-16  浏览次数:20362 次

dwr 2.0实现网页消息发送(jsp)

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page language="java"%>
<%@page buffer="none"%>
<%@include file="../include37/taglib.jsp"%>
<html>
?<head>
??<title id="title">欢迎来到 [星星幼儿园聊天室]</title>

??<script type='text/javascript'
???src='/Kindergarden/dwr/interface/DWRChatManager.js'></script>
??<script type='text/javascript' src='/Kindergarden/dwr/engine.js'></script>
??<script type='text/javascript' src='/Kindergarden/dwr/util.js'></script>
??<link href="${path}/images/chatroom/skin.css" rel="stylesheet"
???type="text/css" />
??<link href="${path}/css/chatstyle.css" rel="stylesheet"
???type="text/css">
??<style type="text/css">
<!--
.STYLE1 {
?color: #0000FF;
?font-weight: bold;
?font-size: 18px;
}
-->
</style>

?


??<!-- 验证登陆JS开始 -->
??<script language="javascript">
?
//捕获关闭按钮
?<!--????
?var isAltF4 = false;?
?var isXClose = false;

?window.onbeforeunload = bunload;

?function bunload()
?{?
????? if (event.clientY < 0 || isAltF4 )?
????? {?
????????? mess = "确定要离开聊天室么?";?
????????? isXClose = true;?
????????? return mess;?
?}
?}
?
?function document.onkeydown()
?{
?? if ((window.event.altKey)&&(window.event.keyCode==115))
?? {
?????? isAltF4 = true;?
????????? bunload();?
????? }?
????? else
????? {?
????????? isAltF4 = false;?
????? }?
??}?
?window.onunload = logoutUser;?
?function logoutUser()?
?{?
???? if (isXClose)?
???? {?
????????? try
????????? {?
????????? ? exit();
????????? ? alert('欢迎您下次再次光临星星幼儿园聊天室!');???
???????????
????????????? return true;?
????????? }?
????????? catch(e)?
????????? {?
????????????? alert('delete user account error message:' + e.message);?
????????? }?
????? }?
?}

// -->??
//退出函数
function exit()
?{
??
??DWRChatManager.exit('${userid}','${speaker}',function(data) {
??
??if (data != null && data.length > 0) {
???window.opener = null;?
???window.open("","_self");?? //fix ie7
???window.close();
??}
?});
?}
function register() {
?var username = document.loginForm.username.value;
?if(username=='')
?{
??alert('请输入您要聊天的昵称!');
??document.loginForm.username.focus();
??return false;
?}
?
?/* 把我输入的用户名注册到服务器,并获得用户id(这里用session id 代替) */
?DWRChatManager.updateUsersList(username, true, function(data) {
??
??if (data != null && data.length > 0) {
???
???if("nameerror"==data)
???{
????alert('该名字已经有人使用,请换一个名字!');
????document.loginForm.username.value="";
????document.loginForm.username.focus();
????return false;
???}
???else
???{?
????Lock_CheckForm();
????document.loginForm.action="${path}/chatroom/chatroom.jsp";
????document.loginForm.submit();
????
???}
???
??}
?});

?
}

/**键盘快捷键登录**/
function loginConfirm()
{
?if(window.event.keyCode==13)
?{
??checkUser();
?}
}

function checkUser()
{
?if(document.getElementById("username").value==null || document.getElementById("username").value=="")
?{
??alert('请问您尊姓大名?');
??document.getElementById("username").focus();
??return false;
?}
?register();
}

</script>
??<!-- 验证登陆JS结束 -->

?

?

?

?

??<script language="javascript">

/**
?* 页面初始化
?*/
?/**系统登录层函数**/
?? function?? locking(){??
?? document.all.ly.style.display="block";??
?? document.all.ly.style.width=document.body.clientWidth;??
?? document.all.ly.style.height=document.body.clientHeight;??
?? document.all.Layer2.style.display='block';??
?? }?? <