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: '.png',
body: "Hey there! You've been notified!"
});
notification.onclick = function () {
window.open("");
}
Is it possible to create a notification that, when is clicked, opens the tab which created that notification?
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/stackexchange/img/logos/so/so-icon.png',
body: "Hey there! You've been notified!"
});
notification.onclick = function () {
window.open("http://stackoverflow./a/13328397/1269037");
}
Is it possible to create a notification that, when is clicked, opens the tab which created that notification?
Share Improve this question edited Apr 6, 2015 at 12:50 Lighty asked Apr 6, 2015 at 12:39 LightyLighty 711 silver badge5 bronze badges2 Answers
Reset to default 14 +250Yes.
notification.onclick = function () {
window.focus();
}
Instead of window.open
, try using:
window.location = "https://stackoverflow./a/13328397/1269037"
That worked for me.