Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Notifications Desktop reminder in HTML5

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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 ();}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report