I am developing a chat with WebSocket and I have a problem, when I send a message to a friend, he receives the desktop notification (from the Browser he is) and when he clicks on the notification he goes to the conversation window of the person who sent the message to him.
WhatIwantisatleastwhentheuserclicksonthenotificationgotothetabwherethechatiswithoutgivingtherefreshofthepage,theexcerptImadewasso,butitrefreshesthepageanddoesnotgotothe" of the chat ":
notification.onclick = function () {
window.open('http://localhost/pullchat', '_self');
};
The complete Notification function code:
//Função de notificação de mensagens
function notifyMe(nome, mensagem, id) {
if (!Notification) {
alert('Notifications are supported in modern versions of Chrome, Firefox, Opera and Firefox.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
var notification = new Notification( nome, {
icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
body: mensagem,
});
//------------------------AQUI QUE ESTÁ O PROBLEMA-------------------------------
notification.onclick = function () {
window.open('http://localhost/pullchat', '_self');
};
}