PHP重载聊天框? [英] PHP reload chat-box?

查看:110
本文介绍了PHP重载聊天框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经像PHP事情聊天框。唯一的问题是,它并不会自动重新加载。有没有一种方法,使之在PHP重装,否则我将不得不四处移动的一切,所以我可以使用AJAX?此外,我的用户是经常在线。我已经将它设置为是因为它们是离线的,如果他们有pressed一个键或点击在最后3分钟,当他们离开网页离线进行设置。他们使用的是Firefox 9.0。是因为使用onunload的呢?什么将是一个解决办法?

I have made a chat box like thing in PHP. The only problem is that it doesn't automatically reload. Is there a way to make it reload in PHP, or would I have to move everything around so I can use AJAX? Also, one of my users is constantly online. I have set it to be that they are offline if they have pressed a key or clicked in the last 3 minutes and to set them offline when they leave the page. They are using Firefox 9.0. Is this because of the use of onunload? What would be a solution?

推荐答案

您可以使用元刷新标签,这可能是由PHP生成,但它不是一个真正的PHP的特定功能。

You could use a meta refresh tag, that could be generated by PHP, but its not really a PHP-specific feature.

<meta http-equiv="refresh" content="600">

这将刷新在600秒后的内容。您可以准确地掐死那个时候更多的基于应用程序的需求。

This will refresh the content after 600 seconds. You could throttle that time more accurately based on your applications demands.

阿贾克斯大概是preferred方法检查用户活动。下面是检查用户活动的一个类似的帖子 - <一个href="http://stackoverflow.com/questions/1009260/how-can-i-detect-with-javascript-jquery-if-the-user-is-currently-active-on-the-p">How我能察觉的JavaScript / jQuery的,如果用户在页面上当前活动的?

Ajax is probably the preferred method for checking user inactivity. Here is a similar post on checking user activity - How can I detect with JavaScript/jQuery if the user is currently active on the page?

更新

至于如何处理在Firefox用户退出第二个问题,它就像你说的那个 onunload 可以不一致。这是使用Ajax再次闪耀。如果您的应用程序停止接收来自客户端AJAX更新,你可以做一些清理工作,以将它们标记为非活动状态。

As for the second question of how to handle exit of a user in Firefox, its like you said that onunload can be inconsistent. This is where the use of ajax shines again. If your app stops receiving ajax updates from the client, you can do some sort of cleanup to mark them as inactive.

我们曾在一个ASP.Net MVC应用程序类似的情况。我们结束了使用应用程序变量来存储用户最近的活动和状态。一个PHP的例子可以这里找到。

We had a similar situation in an ASP.Net MVC app. We ended up using Application Variables to store recent activity and state of users. A php example can be found here.

希望这有助于!

这篇关于PHP重载聊天框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆