Add new chat messages in title
Good day to all, please help us solve this problem. There is a chat, and I want to do such a thing, when a person is sitting on other tabs (i.e. not in the chat), in
function updateTitle(){
window.onblur = function(){
if(notread != 0)
$('title').text(notread + ' новых сообщений');
else
$('title').text('ЧАТ СНУЯЭиП');
}
window.onfocus = function(){
notread = 0;
}
}
But the problem is that the data is updated only when I leave the tab, and by itself it is not updated. Tell me how you can update it constantly, without necessarily finding a person on this tab? The analog can be seen in the Vkontakte dialogs.
0
1 answers
var refresh_interval = setinterval(function(){
if(notread != 0)
$('title').text(notread + ' новых сообщений');
else
$('title').text('ЧАТ СНУЯЭиП');},1000);//1000мс = 1секунда
//Чтобы остановить обновление
clearinterval(refresh_interval);
2
Author: knes, 2014-08-25 12:11:29