电脑维修第一互动门户_www.PC106.com 为了方便您再次访问电脑维修站,请点击收藏本站!设为首页
操作系统 · 硬件学院 · 软件学院 · 网络学院 · DIY 经验 · 数据恢复 · 网站技术 · 维修网点 · IT 黄 页 · 大师答疑
故障症状 · 电脑优化 · 病毒快报 · 黑客安全 · 维修宝典 · 电脑保养 · 服 务 器 · 在线杀毒 · 在线电视 · 网址服务
维修 CPU·主板·硬盘·内存·显卡·显示器·键盘鼠标·声卡音箱·软驱光驱·打印机·机箱电源·BIOS·网卡·局域网·浏览器
您现在的位置: 电脑维修 >> 网站技术 >> PHP技术 >> 入门教程 >> 网站技术正文
聊天室技术(五) -- 指挥中心
作者:佚名 文章来源:不详 点击数: 更新时间:2007-2-2 9:52:59

这里是聊天室的指挥中心,所有的指令都要在这里发出

1下面是基本的发送表单代码

<form name=inputform action='messagesend.php' target='bl' onsubmit='return(checksay());' method=POST>

<?
//下面的2个参数用于验证信息的正确性
print("<input type='hidden' name='name' value='$name'>n");
print("<input type='hidden' name='pass' value='$pass'>n");
?>

//聊天对象,注意加上 readonly 属性
<input type="text" name="talkto" size="10" maxlength="20" readonly value="所有人">

//上次聊天的发送内容
<input type='hidden' name='message' value=''>

//发送的表单文本框
<input type="text" name="msg" maxlength="120" size="34">

<input type="submit" name="Submit" value="发送">

</form>

2 检查发送内容的js

var dx ='';
function checksay( )
{

//不允许发送空的发言
if(document.inputform.msg.value=='')
{
document.inputform.msg.focus();
return false;
}

//不允许重复发言,内容相同,对象相同
if ((document.inputform.msg.value==document.inputform.message.value)&&(document.inputform.talkto.value==dx))
{
alert('发言不能重复');
document.inputform.msg.focus();
return false;
}

//两次发言内容的间隔不能小于1秒,或者发言字数大于间隔*3
t2=(new Date()).getTime()/1000;
if(((t2-t1)<1)||((t2-t1)*3<document.inputform.msg.value.length))
{
document.inputform.msg.focus();
return false;
}

//更新时间
t1=t2;

document.inputform.showsign.value=1;

//保存上次发言内容
document.inputform.message.value =document.inputform.msg.value;

//清空发言内容
document.inputform.msg.value ='';

//保存发言对象
dx=document.inputform.talkto.value;

//定位焦点
document.inputform.msg.focus();

//返回
return(true);
}

3调用信息发送程序,发布聊天者已经进入的信息
<script>
parent.bl.document.open();
parent.bl.document.write("<meta http-equiv='refresh' content='0;url=messagesend.php?name=<? print($name); ?>&&action=enter&&pass=<? print($pass); ?>'>")
parent.bl.document.close();
</script>

发言由messagesend.php处理完成,注意输出对象为bl,也就是处理发言的框架名称,这样保证发言框架的页面内容的完整

原作者:howtodo
来源:php2000.com





上网速度更快更爽、更安全下载使用Firefox火狐浏览器

网站技术录入:admin    责任编辑:admin 
  • 上一篇网站技术:

  • 下一篇网站技术:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

     IT图片报道

    14万元天价!640GB闪存硬盘美国问

    双核独显19寸液晶惠普PC机只卖49

    佳能MP160售价仅580元

    神舟双核液晶电脑3999起
     IT热点报道

    普通IT报道 中国电信称三年内实现光纤到户
    普通IT报道 广达个人电脑宣布已开始在江苏投入量产
    普通IT报道 14万元天价!640GB闪存硬盘美国问世
    普通IT报道 节后病毒猖獗系统瘫痪
    普通IT报道 AMD推出6款节能处理器
    推荐IT报道 双核独显19寸液晶惠普PC机只卖4999元
    普通IT报道 微软无奈下调Vista销售预期 XP仍是主角
    普通IT报道 佳能MP160售价仅580元
    推荐IT报道 神舟双核液晶电脑3999起
    推荐IT报道 4999元玩Vista 七喜12寸轻薄本升级
    关于公司 | 免责声明 | 广告服务 | 招贤纳士 | 联系我们 | 友情链接 1 2 3
    Copyright©2005 - 2007  http://www.PC106.com  All Right Reserved   
    桂ICP备06015569号

    技术咨询
    22097366
    10231086
    30636841
    技术交流群
    27717914