Perhaps this is a fairly big and ambiguous question:
In the Stack Overflow chatrooms, there is a button to "enable desktop notifications," which will show something in the system tray when someone replies to you.
By what mechanism does this work? It's always made me curious.
How does a website access the system tray?
Perhaps this is a fairly big and ambiguous question:
In the Stack Overflow chatrooms, there is a button to "enable desktop notifications," which will show something in the system tray when someone replies to you.
By what mechanism does this work? It's always made me curious.
How does a website access the system tray?
Share Improve this question edited Apr 10, 2015 at 1:05 Jeremy Banks - Vive le Canada 130k88 gold badges358 silver badges381 bronze badges asked May 11, 2014 at 15:44 corvidcorvid 11.2k12 gold badges70 silver badges134 bronze badges 2- 11 Each browser implements this. The functionality is called "Desktop notifications". Here is a link for mozilla and here is one for chrome. – Lix Commented May 11, 2014 at 15:46
- Here's Safari – AstroCB Commented May 11, 2014 at 16:09
3 Answers
Reset to default 16It uses the Notification
object (i.e. var n = new Notification("Hello");
) to provide local notifications on a per-website basis. Each browser implements the standard differently (see Chrome, Firefox, and Safari), but they all operate essentially the same way, sending notifications based on the permissions they have (window.Notification.permission
), which can be default
(hasn't been asked, in which case you would window.Notification.requestPermission();
), granted
, or denied
. Opera and Internet Explorer do not support desktop notifications at this time.
They're called Desktop Notifications, which use the Notifications API.
Basically, the site checks for Notifications API support, then the user grants or denies the website permission to display notifications.
Here is more information on how the API works.
This is with the help of WebSockets - Web APIs. There is actually a persistent connection between the client and the server. And also both parties can start sending data at any time.