Discuz!大师网

搜索
查看: 1129|回复: 4

关于新消息提醒的问题,希望知道的朋友帮忙指点下,代码如下

[复制链接]
发表于 2014-2-20 19:23:05 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
js页面代码如下:

setInterval("check_news()",10000); //10s
function check_news(){
var xmlhttp;
if (window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}
else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
if(xmlhttp.responseText>0){
alert("new message!");
}else{
alert(xmlhttp.responseText);
}
}
}
xmlhttp.open("GET","newmessage.php?t=" + Math.random(),true);
xmlhttp.send();
}

newmessage.php页面代码如下:





回复 马甲回复

使用道具 举报

 楼主| 发表于 2014-2-20 20:03:51 | 显示全部楼层
请问怎么样才能让前台显示有未读消息呢
发表于 2014-2-20 20:00:42 | 显示全部楼层
这个不是弹了对话框了 有消息alert了啊。
发表于 2014-2-20 20:30:30 | 显示全部楼层
这种方法对 浏览器要吃不消的吧
发表于 2014-2-23 18:40:45 | 显示全部楼层
也遇到这样的问题  你解决了吗  求分享
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|网站地图|小黑屋|展会网|Discuz站长论坛 |天天打卡

GMT+8, 2024-5-5 00:43 , Processed in 0.049625 second(s), 6 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表