我希望弹出式聊天或弹出窗口,当聊天更新像Gmail ... 例如,如果我在其他标签和Gmail聊天更新,那么它显示标题.. 我只是想要这种类型的代码,显示当我的数据库更新或每10秒后,一旦我点击它,那么它不应该再次显示......javascript提醒像Gmail聊天更新聊天
0
A
回答
0
我曾经为html5通知写一个插件,它可以轻松地创建通知:
/**
* Notification
* @author: ijse
* @require: Chrome10+
* @params: Same as webkitNotifications.create[HTML]Notification()
* @usage:
* new Notify("http://www.baidu.com").onshow(function() {
* alert("show");
* }).onclose(function() {
* alert("close");
* }).show();
*/
window.Notify = function() {
var _params = arguments;
// Validate arguments
if(_params.length == 0) {
console.error("Notify need at least one argument");
return ;
}
// Check browser support
if(!window.webkitNotifications) {
console.error("Your browser does not support webkitNotifications feature!!");
return ;
}
var _onclose, _onclick, _onerror, _onshow;
var _notification, _replaceId, _showFlag = false;
function bindEvents() {
// Add event listeners
// In W3C, display event is called show
_notification.addEventListener("display", _onshow, false);
_notification.addEventListener("click", _onclick, false);
_notification.addEventListener("error", _onerror, false);
_notification.addEventListener("close", _onclose, false);
if(_replaceId)
_notification.replaceId = _replaceId;
// !!IMPORTANT&&WEIRD!! remove next line no events will work
var t = _notification;
}
function createfn(permission) {
// About permission on Chrome:
// PERMISSION_ALLOWED (0) indicates that the user has granted permission to scripts with this origin to show notifications.
// PERMISSION_NOT_ALLOWED (1) indicates that the user has not taken an action regarding notifications for scripts from this origin.
// PERMISSION_DENIED (2) indicates that the user has explicitly blocked scripts with this origin from showing notifications.
if(permission == 0) {
// If permission is allowed
// Create notification
if(_params.length == 1)
_notification = window.webkitNotifications.createHTMLNotification(_params[0]);
else
_notification = window.webkitNotifications.createNotification(_params[0],_params[1],_params[2]);
// Bind events
bindEvents();
// Show, if yes flag
!!_showFlag && _notification.show();
} else {
if(_onerror)
_onerror.call(this);
console.error("Notification permission is denied!!");
}
}
// If permission already allowed, do not require again
if(window.webkitNotifications.checkPermission() != 0) {
// Require permission from user
window.webkitNotifications.requestPermission(function() {
createfn.call(this, window.webkitNotifications.checkPermission());
});
} else {
createfn.call(this, window.webkitNotifications.checkPermission());
}
// Return handler methods
return {
onclose: function(fn) { _onclose = fn; return this; },
onclick: function(fn) { _onclick = fn; return this; },
onerror: function(fn) { _onerror = fn; return this; },
onshow : function(fn) { _onshow = fn; return this; },
show: function(replaceId) {
_replaceId = replaceId;
if(_notification) {
// Notification already been created
bindEvents();
_notification.show();
} else {
// Flag yes to show
_showFlag = true;
}
return _notification;
},
cancel: function() {
_notification.cancel();
}
} // return handler
}
0
而不是JavaScript,您可以使用调用php页面的ajax函数。使用数组来累积所有消息。你说你每10秒钟检查一次该页面。在聊天窗口中显示数组值。然后重置数组为空。然后再次执行相同的过程。希望这个概念能起作用。我不确定。如果你想在JavaScript中这个。你应该使用js数组中的值。
相关问题
- 1. 聊天消息提醒,如Gmail提醒
- 2. 群聊聊天圈像网络聊天像Facebook群聊天UI
- 3. Gmail聊天:心脏
- 4. Javascript提交Facebook聊天
- 5. Gmail中的PHP聊天
- 6. 自动更新聊天室
- 7. 如何正确处理聊天页面中的“聊天更新”?
- 8. Quickblox头像聊天
- 9. 聊天
- 10. java:语音聊天和文字聊天
- 11. sql聊天群组同样聊天
- 12. ASP.NET文本聊天和视频聊天
- 13. 实现发送文件在facebook聊天像facebook聊天
- 14. Laravel聊天消息。保存图像发送聊天?
- 15. 聊天表单不提交
- 16. 如何创建JavaScript聊天
- 17. 与唯一的javascript聊天?
- 18. 小javascript/ajax/mysql聊天
- 19. Javascript + Pubnub聊天室通知
- 20. 纯javascript聊天对话
- 21. javascript聊天显示消息
- 22. 使用javascript进行聊天
- 23. 像聊天一样的facebook
- 24. 谷歌聊天像Div
- 25. 如何创建Gmail聊天?如何连接到AIM并允许AIM聊天?
- 26. 聊天UI库
- 27. Facebook聊天API
- 28. JAVAFX ListView聊天
- 29. 聊天通讯
- 30. 银灯聊天
如何使用类似Growl的弹出窗口? http://webtoolkit4.me/2009/08/13/jquery-growl-likenotification-systems/ – djot 2011-12-17 06:13:09