今天2016-11-18号,最新chrome版本:V50

在网上找了好久都用不了,因为chrome版本已经是V50了,chrome在V22版本之后就取消掉window.webkitNotifications通知。

chrome现在走的是w3c标准化。

W3C中关于通知文档:

https://www.w3.org/TR/notifications/

直接上代码:

<!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'>
Notification.requestPermission();
document.querySelector("#btn").addEventListener('click', notify, false); function notify() { var notification = new Notification("标题:程序",{
body : "内容content",
icon : 'http://images0.cnblogs.com/news_topic/firefox.gif',
sound:audioNotification(),
tag : {} // 可以加一个tag
});
} function audioNotification(){
var yourSound = new Audio('http://df.notf.com/a.mp3');
yourSound.play();
}
</script>
</body>
</html>

通过ajax定时获取后台是否有内容需要提醒,可以写一个方法

notify('**同学,有新的订单提交','订单号:1202100');
function notify(title,content) { var notification = new Notification("title",{
body :content,
icon : 'http://images0.cnblogs.com/news_topic/firefox.gif',
sound:audioNotification(),
tag : {} // 可以加一个tag
});
}

可实行桌面通知,带标题、内容、图标,重要的是可以有声音提示。

参考:http://www.cnblogs.com/guangxiaoluo/p/4182500.html

最新文章

  1. ios获取设备信息总结
  2. jarsigner签名报错Invalid keystore format
  3. Getting Started with JD Edwards EnterpriseOne Interoperability
  4. Mac OS X下重启apache
  5. Gson解析的小例子
  6. Pureftp-安全的ftp服务器部署
  7. [CareerCup] 6.4 Blue Eyes People on Island 岛上的蓝眼人
  8. LinuxC语言读取文件,分割字符串,存入链表,放入另一个文件
  9. suibi11172
  10. xml格式化写入文件
  11. 一些Android经验
  12. 面试(3)-java-se-java中的匿名内部类总结
  13. 简单Elixir游戏服务器-安装Elixir
  14. Linux用命令启动程序(eclipse、IDEA等)
  15. MT【33】证明琴生不等式
  16. 【codeforces 175D】 Plane of Tanks: Duel
  17. 关于 RabbitMQ 的 Dead-Letters-Queue “死信队列”
  18. 消息中间件activemq-5.14.1安全验证配置
  19. c++多态特性总结
  20. mysql创建utf8数据库

热门文章

  1. java 反射
  2. gprs/gsm 在linux下的应用
  3. mysql 主从单库单表同步 binlog-do-db replicate-do-db
  4. vtkTransform实例 1
  5. netlink优势
  6. 现代软件工程作业 github使用
  7. html 杂记
  8. Oracle 如何扩展表空间
  9. JavaWeb监听器的使用(一)监听上下文和会话信息
  10. Android 常用开发工具以及Mac常用软件