1.下面的代码加在<head>和</head>之间--请把其中的IP和端口换成你自己的就可以了(其中:202.102.135.71是IP,9999是端口)。
<script language=javascript> <!-- function OnLogin() // 登录聊天室 { if(!validstr(login.user)) return ; //var strBox = "" ; window.open("about:blank", "iChatMain", "toolbar=no,location=no,directories=no,menubar=no,resizable=yes") ; login.submit() ; } function OnRegister() { window.open("http://202.102.135.71:9999/Register","_Register","toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=yes,width=270,height=400"); } function validstr(str) // 验证用户名 { var s,i,j; s=" +=|'#&<>%*`^/\\\";,."; str1=str.value.toString(); if (str.value.length <1){alert("呢称不能为空!");str.focus(); return false;} for (i=0; i<str1.length; i++) { for(j=0;j<s.length;j++) {if (str1.charAt(i) == s.charAt(j)) { alert("名字中不能包含特殊字符: +=|'#&<>%*`^/\\\";,.空格."); str.focus(); return false; }}}return true; } //--> </script>
2. 下面的代码放到<BODY>里
<form name="login" action="http://202.102.135.71:9999/login" method="post" target="iChatMain"> 呢称:<input type="text" name="user" maxlength=12 size=10> 密码:<input type="password" name="pass" maxlength=12 size=10> <input type="checkbox" name="boxfunc">启用包厢 性别:<input type="radio" name="radio1" onClick="login.sex.value=0;">女<input type="radio" name="radio1" onClick="login.sex.value=1;">男<input type="radio" name="radio1" onClick="login.sex.value=2;">保密 [<a href="javascript:OnRegister();">注册呢称</a>] [<a href="javascript:OnLogin();">进入</a><input type="hidden" name="sex">] </form>