Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go to an already opened tab when a Chrome Notification is clicked

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?

like image 564
Lighty Avatar asked Apr 06 '15 12:04

Lighty


People also ask

How do I view Chrome notifications?

Go to Settings > Privacy and Security > Site Settings, then scroll down to Notifications in the pop-up window that appears. From there, you can toggle the Sites Can Ask to Send Notifications switch that turns website notification prompts on or off.

When I open Google Chrome a bunch of Notifs pop up?

Under “Privacy and security,” click Site settings. Click Notifications. Choose to block or allow notifications: Allow or Block all: Turn on or off Sites can ask to send notifications.


1 Answers

Yes.

notification.onclick = function () {
  window.focus();
}
like image 74
Zectbumo Avatar answered Nov 15 '22 04:11

Zectbumo