nbsp; //get user GUID from url userid = location.search.substring( 1, location.search.length ); //construct Ajax Server URL url = 'Server.aspx?action=PostMsg&u=' + userid + '&t=' + encodeURIComponent(chat) + '&session=' + rnd; //Create and set the instance //of appropriate XMLHTTP Request object req = getAjax(); //Update page with new message req.onreadystatechange = function(){ if( req.readyState == 4 && req.status == 200 ) { updateAll(); } } req.open( 'GET', url, true ); req.send( null ); } 就这么多,没什么特别的,你可以看源代码,里面有很多注释信息。
结 论
要用Java Applet建一个chat room需要在用户的机器上安装JVM。用ActiveX control存在一些安全问题。而用刚才介绍的AJAX,你却可以轻而易举的创建一个基于HTTP并不需要用户安装任何软件就可以运行的聊天室程序,并且很容易维护。 http://www.cnblogs.com/michaelxu/archive/2006/12/19/596872.html 上一页 [1] [2] [3] [4] |