A continuación se muestra un ejemplo de trabajo de notificaciones en el escritorio de Chrome, Firefox, Opera y Safari, copiados de Chrome desktop notification example.
Pruébalo en vivo on JSBin.
// request permission on page load
document.addEventListener('DOMContentLoaded', function() {
if (Notification.permission !== "granted")
Notification.requestPermission();
});
function notifyMe() {
if (!Notification) {
alert('Desktop notifications not available in your browser. Try Chromium.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
else {
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("https://stackoverflow.com/a/13328397/1269037");
};
}
}
<button onclick="notifyMe()">Notify me!</button>
Más información acerca de cómo funciona esto en mi respuesta a Chrome desktop notification example.
Para mostrar la notificación de un sitio web como una ventana emergente, puede utilizar *** alert ***. –
@harry. Gracias, pero estoy buscando una solución que también sea buena práctica. – reshefm
¿cómo hacer lo mismo con windowsforms en asp.net? @reshefm –