I am implementing desktop notifications in a website which displays notifications when new messages arrive. I want the browser tab in which the site is open to get focus when the user clicks on the notification & I could get this worked in Chrome with the following code:
var n = new Notification('Title', {
'body': 'Sample content.'
});
n.onclick = function (e) {
window.focus();
};
But unfortunately, this doesn't work in Firefox. :( Could anyone tell me what I am missing here? I am testing in Chrome 31 & Firefox 26
Thanks.
Go to the browser menu and select "Settings." On the left, click on "Privacy & Security." Scroll down to the "Permissions" window, and select "Notification." If you want to disable notifications, check "Pause notifications until Firefox restarts." Thus, notifications will not appear until you restart Firefox.
Android or iOS: Select Menu > Settings > Notifications. Toggle Product and feature tips on or off to enable or disable notifications.
Website notifications appear the same on Android devices. To block Firefox notifications on your smartphone, go to the browser menu. Next to 'Product and feature tips', turn the toggle switch to 'Off'.
In Firefox focusing window from JS is disabled due to security reasons. You have to switch flag dom.disable_window_flip to false in about:config. But by default it is disabled. The interesting moment is that in Chrome focusing window is disabled too except in response to user actions (such as click) and that's only reason why clicking on notifications works in Chrome.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With