今天惊奇的发现,chrome22里已经不支持window.webkitNotifications.createHTMLNotification方法了:

但是,在chrome extension里还可以继续使用,比如fehelper里的页面性能检测功能:

Google这是要干嘛?逐步实现自己的w3c标准化?

Web Notification在w3c中确实没有createHTMLNotification这样的方法,甚至没有createNotification。

而是一个及其简单构造器:

var notification = new Notification("我的消息",{
    body : '内容',
    iconUrl : '图标',
    tag : {}, // 可以加一个tag
});
notification.show();

貌似目前也只有chrome里面才有这个API:

改写后为:

<!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() {
if (window.webkitNotifications) {
console.log(123);
if (window.webkitNotifications.checkPermission() == 0) {
var notification_test = window.webkitNotifications.createNotification("http://images.cnblogs.com/cnblogs_com/flyingzl/268702/r_1.jpg", '标题', '内容'+new Date().getTime());
notification_test.display = function() {}
notification_test.onerror = function() {}
notification_test.onclose = function() {}
notification_test.onclick = function() {this.cancel();} notification_test.replaceId = 'Meteoric'; notification_test.show(); var tempPopup = window.webkitNotifications.createHTMLNotification(["http://www.baidu.com/", "http://www.soso.com"][Math.random() >= 0.5 ? 0 : 1]);
tempPopup.replaceId = "Meteoric_cry";
tempPopup.show();
} else {
window.webkitNotifications.requestPermission(notify);
}
} else {
console.log(456);
var notification = new Notification("我的消息",{
body : '内容',
iconUrl : 'https://dn-st.b0.upaiyun.com/v4.9.x/images/49751d86.touch-icon-ipad.png',
tag : {} // 可以加一个tag
});
notification.show();
}
}
</script>
</body>
</html>

注:以上红色部分为新增chrome新版弹窗通知功能

chrome 不支持window.webkitNotifications.createNotification消息通知API了的更多相关文章

  1. 高版本chrome不再支持window.showmodaldialog 的临时替换方案【用window.open】

    接管别人的项目,因开发时用了showmodaldialog 导致最近很多用户chrome升级到最新之后 就无法弹窗了.原因是新版chrome[37+]不再支持showmodaldialog. show ...

  2. 谷歌chrome浏览器桌面提醒 webkitNotifications

    原创: //点击时开启提醒 $(".message_alert").toggle(function(){ $(".message_alert_tip").htm ...

  3. 高版本Chrome不支持showModalDialog

    高版本Chrome不支持window.showModalDialog,可用window.open代替 var url = "https://www.baidu.com"; var ...

  4. window 如何枚举设备并禁用该设备和启用该设备?如何注册设备热拔插消息通知?

    目前实现的功能: 1.设备枚举 2.设置设备禁用和启用 3.注册设备热拔插消息通知 4.获取设备 vid pid 数值 需要链接的库 SetupAPI.lib DeviceManager 类如下: D ...

  5. HTML 5的消息通知机制

    译文来源:http://www.ido321.com/1130.html 原文:HTML 5 Notification 译文:HTML 5 的消息通知机制 译者:dwqs HTML 5 已经被应用到W ...

  6. 杂谈:HTML 5的消息通知机制

    译文来源:http://www.ido321.com/1130.html 原文:HTML 5 Notification 译文:HTML 5 的消息通知机制 译者:dwqs watermark/2/te ...

  7. 使用 Windows10 自定义交互消息通知

    消息通知是最常用的应用功能之一了,但是由于平台的差异,IOS Android 以及 Windows 都有其特殊性,Android开发者在国内常常都是使用三方的一些推送服务,或者是使用自建的服务器为应用 ...

  8. UWP消息通知

    在Windows 10通常是使用Toast通知方式进行的消息通知,但是在应用通知是不需要通知带有音效的,但是又不能在系统通知中心留下记录,那么需要监听ToastNotification实例的Dismi ...

  9. Redis系列二之事务及消息通知

    一.事务 Redis中的事务是一组命令的集合.一个事务中的命令要么都执行,要么都不执行. 1.事务简介 事务的原理是先将一个事务的命令发送给Redis,然后再让Redis依次执行这些命令.下面看一个示 ...

随机推荐

  1. 模仿iframe框架,由分隔栏动态改变左右两侧div大小———基于jQuery

    <!DOCTYPE html><html lang="zh-cn"><head> <meta charset="utf-8&qu ...

  2. hdu2874 LCA在线算法

    Connections between cities Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (J ...

  3. Python笔记(4)类__属性与描述符

    部分参考自:http://www.geekfan.net/7862/ 新式类与经典类 2和3不一样,3都是新式类. 新式类和经典类的区别: class A: #classic class " ...

  4. html5离线应用和缓存

    1 localstorage和sessionstorage sessionStrage: session即会话的意思,在这里的session是指用户浏览某个网站时,从进入网站到关闭网站这个时间段,se ...

  5. CentOS 6.7下利用Rsyslog+LogAnalyzer+MySQL部署日志服务器

    一.简介 LogAnalyzer 是一款syslog日志和其他网络事件数据的Web前端.它提供了对日志的简单浏览.搜索.基本分析和一些图表报告的功能.数据可以从数据库或一般的syslog文本文件中获取 ...

  6. 平衡二叉查找树(AVL)的理解与实现

    AVL树的介绍 平衡二叉树,又称AVL(Adelson-Velskii和Landis)树,是带有平衡条件的二叉查找树.这个平衡条件必须要容易保持,而且它必须保证树的深度是 O(log N).一棵AVL ...

  7. Python之路【第二十篇】其他WEB框架

    WEB框架功能分析 WEB框架本质上,就是一个SOCKET Server WEB框架前面有WSGI或者是自己写的SOCKET,然后交给URL路由系统处理,然后交给某个函数或某个类,然后在模板里拿到模板 ...

  8. junit学习笔记

    junit编程规范 测试方法上必须使用@Test进行修饰 测试方法必须使用public void 进行修饰,不能带任何的参数 新建一个源代码目录 测试类的包应该和被测试类保持一致 测试单元中的每个方法 ...

  9. MySql 里的IFNULL、NULLIF和ISNULL用法区别

    mysql中isnull,ifnull,nullif的用法如下: isnull(expr) 的用法:如expr 为null,那么isnull() 的返回值为 1,否则返回值为 0. mysql> ...

  10. 问题解决:psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

    错误提示: psql: could not connect to server: No such file or directory Is the server running locally and ...