6

Javascript in a web page (not a Chrome app or extension) can create a Chrome desktop notification, and set an URL to be opened when the notification is clicked.

var notification = new Notification('Notification title', {
  icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
  body: "Hey there! You've been notified!"
});

notification.onclick = function () {
  window.open("http://stackoverflow.com/a/13328397/1269037");
}

Is it possible to create a notification that, when is clicked, opens the tab which created that notification?

Lighty
  • 61
  • 1
  • 5

2 Answers2

12

Yes.

notification.onclick = function () {
  window.focus();
}
Zectbumo
  • 3,339
  • 29
  • 23
2

Have you tried using window.location = "https://stackoverflow.com/a/13328397/1269037" rather than window.open? It has worked for me.

Community
  • 1
  • 1