チャットやポップアップにポップアップが必要な場合は... 私が他のタブにいて、Gmailのチャットが更新されていればタイトルに.. ちょうど私が一度で、HTML5の通知のためのプラグインを作成Gmailのチャットのようなチャットのチャットでチャットのチャットが行われたとき
0
A
答えて
0
....私のデータベースが更新されたときを示すか、10秒ごとの後、私はそれをクリックした後、それが何度も何度も表示されてはならないこの種のコードをしたいです
/**
* 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. android:チャットのようなリストビュー
- 2. Quickbloxチャット接続がアンドロイドでチャットするときにドロップ
- 3. チャットAPI - TokBoxのようなサービスですが、テキストベースのチャットは可能ですか?
- 4. zopimチャット
- 5. Facebookのチャット
- 6. チャットのクロスブラウザテキストエリア
- 7. Jqueryチャットのハウツートラックユーザーセッション
- 8. Androidチャットとロングポーリング
- 9. androidのローカルエリアネットワークでチャット
- 10. チャットでビデオプラグイン。
- 11. ウェブアプリケーションでチャット
- 12. UDPチャットJavaで
- 13. UDPチャットでアンドロイド
- 14. スクリプトでチャット
- 15. チャットではネイティブネイティブ
- 16. JMSとの簡単なチャット
- 17. チャットアプリ - Socket.IO/Angular/MongoDB - チャットとチャットの履歴が表示されない
- 18. Mediatorパターンの例:チャット
- 19. socket.io/node.jsのXSSチャット?
- 20. ボットフレームワークエミュレータVSのWebチャット
- 21. チャットの作成 - PHP
- 22. C#:インスタントメッセンジャーのリッチテキストボックス(チャット)
- 23. チャットSmartsupp-Drupalのスクリプト
- 24. HTTPリクエストベースのAndroidチャット
- 25. Javascriptチャットのテキストを
- 26. 角度2のチャット
- 27. Phpチャットの実装
- 28. Androidチャット自分のリソースでチャット/サーバーからライブデータを取得
- 29. PHP/MYSQL AJAXチャット
- 30. ユニティXMPPチャット
育つようなポップアップを使用するとどうなりますか? http://webtoolkit4.me/2009/08/13/jquery-growl-likenotification-systems/ – djot