我希望彈出式聊天或彈出窗口,當聊天更新像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. Javascript提交Facebook聊天
- 2. 自動更新聊天室
- 3. Quickblox頭像聊天
- 4. 聊天
- 5. ASP.NET文本聊天和視頻聊天
- 6. sql聊天羣組同樣聊天
- 7. java:語音聊天和文字聊天
- 8. Javascript - 如何將索引聊天轉換爲聊天窗口
- 9. Laravel聊天消息。保存圖像發送聊天?
- 10. 實現發送文件在facebook聊天像facebook聊天
- 11. Javascript + Pubnub聊天室通知
- 12. javascript聊天顯示消息
- 13. 使用javascript進行聊天
- 14. 與唯一的javascript聊天?
- 15. 谷歌聊天像Div
- 16. 如何創建Gmail聊天?如何連接到AIM並允許AIM聊天?
- 17. Facebook聊天API
- 18. Laravel WebSocket聊天
- 19. Android xmpp聊天
- 20. 與express.io聊天
- 21. 實時聊天
- 22. JAVAFX ListView聊天
- 23. 聊天通訊
- 24. 聊天應用程序 - Socket.IO/Angular/MongoDB - 不顯示聊天和聊天記錄
- 25. 最新的聊天室!y
- 26. 從聊天服務器發送到聊天客戶端的數組更新
- 27. Unity網絡聊天,需要圍繞命令更新聊天的方式
- 28. 如何在java聊天中更新JList
- 29. 實時更新聊天腳本
- 30. 聊天+地圖= NoSuchMethodError:com.google.firebase.FirebaseApp.zzUV
如何使用類似Growl的彈出窗口? http://webtoolkit4.me/2009/08/13/jquery-growl-likenotification-systems/ – djot 2011-12-17 06:13:09