Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use Notifications Desktop reminder in HTML5

Shulou Source: shulou.com Published: 2022-06-03 12:13:53 10月01日 Update

This article mainly shows you "how to use Notifications desktop reminders in HTML5". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn how to use Notifications desktop reminders in HTML5.

Undefinedundefinedundefined

Example

HTML5-Notifications// determines whether the browser supports Notificationsfunction supported () {if (window.webkitNotifications) {alert ('browser supports Notifications');} else {alert (' browser does not support Notifications');}} / / request desktop notification permission function requestPermission () {window.webkitNotifications.requestPermission () } / / get request permission status function checkPermission () {switch (window.webkitNotifications.checkPermission ()) {case 0:alert ('user has been allowed to display desktop notifications'); break; case 1:alert ('user has not allowed or refused to display desktop notifications'); break; case 2:alert ('user has refused to display desktop notifications'); break }} / / create a text message function textMsg () {var icon = 'logo.png'; var title =' Ah Peng\'s BLOG'; var body = 'http://www.1990c.com'; var popup = window.webkitNotifications.createNotification (icon, title, body) Popup.ondisplay = function (event) {setTimeout (function () {event.currentTarget.cancel ();}, 5000);} popup.show ();} / / create HTML message function htmlMsg () {var popup = window.webkitNotifications.createHTMLNotification ('msg.html') Popup.ondisplay = function (event) {setTimeout (function () {event.currentTarget.cancel ();}, 5000);} popup.show ();}

Tags: Desktops content browsers users articles support browsing permissions messages learning help text easy to understand more organization status knowledge examples editing industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple macOS Shulou Information Docker NVidia