js实现桌面通知
来源:互联网 发布:网络借贷能分期吗 编辑:程序博客网 时间:2024/05/22 09:38
<!DOCTYPE html><html><head><title>Google 桌面通知</title><meta name="generator" content="editplus" /><meta name="author" content="" /><meta name="keywords" content="" /><meta name="description" content="" /><meta http-equiv='content-type' content='text/html; charset=utf-8' /></head><body><button id='btn'>显示桌面通知</button><script type='text/javascript'>document.querySelector("#btn").addEventListener('click', notify, false);function notify() {showMsgNotification('这里填入标题','这里是消息的内容');}function showMsgNotification(title, msg, icon) {var options = {body: msg,icon: icon||"image_url"};var Notification = window.Notification || window.mozNotification || window.webkitNotification;if (Notification && Notification.permission === "granted") {var instance = new Notification(title, options);instance.onclick = function() {// Something to do};instance.onerror = function() {// Something to do};instance.onshow = function() {// Something to do//setTimeout(instance.close, 3000);setTimeout(function () {instance.close();},3000)console.log(instance.body)};instance.onclose = function() {// Something to do};console.log(instance)} else if (Notification && Notification.permission !== "denied") {Notification.requestPermission(function(status) {if (Notification.permission !== status) {Notification.permission = status;}// If the user said okayif (status === "granted") {var instance = new Notification(title, options);instance.onclick = function() {// Something to do};instance.onerror = function() {// Something to do};instance.onshow = function() {// Something to dosetTimeout(instance.close, 3000);};instance.onclose = function() {// Something to do};} else {return false}});} else {return false;}}</script></body></html>
必须在服务器环境下
0 0
- js实现桌面通知
- 前端js实现桌面通知
- window.Notification实现桌面通知
- 使用HTML5 Notification实现桌面通知
- js chrome 桌面通知(必须在服务器下)
- js实现浏览器通知功能
- Html5 API之Notification对象实现桌面通知
- Web Notification简单实现桌面消息通知(右下角提示)
- Chrome的桌面通知
- HTML5 Notifications桌面通知
- 桌面弹出通知
- HTML5的桌面通知
- HTML5 桌面通知
- 桌面通知 【转载】
- [html5] (Notification) 桌面通知
- HTML5桌面通知
- 桌面通知-Notification
- html5桌面通知
- 设置eclipse默认打开文件方式
- Android 修改通知栏一条信息的显示高度
- 个人常用iOS第三方库以及XCode插件介绍
- AngularJS入门小结
- Linux网络编程:原始套接字的魔力【下】
- js实现桌面通知
- 蓝牙的应用
- 【JAVA】反射工具类
- 全栈工程师-那些经常用的前端知识小结
- C#基础知识图谱
- eclipse自定义注释
- Xcode 报错: Type '**Controller' does not conform to '**Delegate
- Java到底是传引用还是传值?
- javascript 利用hash实现行列转置