今天惊奇的发现,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. shell中测试命变量是否已经定义

    (1)sehll实例 # cat subshell #!/bin/bash if (set -u; : $var); then #冒号与$间有空格 echo "Variable is set ...

  2. 公司VPN信息

    公司VPN证书信息(请妥善留档本邮件) 管理 管理员 <admin@pansoft.com> 2016/12/12 11:00   收件人: huhuan@pansoft.com   × ...

  3. UIDynamic(重力行为+碰撞检测)

    一.重力行为 说明:给定重力方向.加速度,让物体朝着重力方向掉落 1.方法 (1)UIGravityBehavior的初始化 - (instancetype)initWithItems:(NSArra ...

  4. iOS 分析一个支持GIF的UIImage扩展:SwiftGIF

    Github:https://github.com/bahlo/SwiftGif 这个extension代码不多,主要通过Apple的ImageIO框架进行解析GIF. 整个扩展最核心还是下面的函数, ...

  5. C#之字符串篇

    大杂烩 一.类型转换    字符串转整形: int a = int.Parse(""); //不能转换null int b = Convert.ToInt32("&quo ...

  6. 如何学好JAVA编程

    我的思路:     1.我觉得先学学JSP,用纯JSP做个日记本简单的小系统,纯粹从语言层面上了解一些基   础知识,把tomcat玩熟了,就用记事本编就行,主要是熟悉,能够理解jsp运行机制.然   ...

  7. SDL鼠标事件

    鼠标事件有这么多种,手柄的可以忽视,Sdl.SDL_KEYDOWN,Sdl.SDL_KEYUP,Sdl.SDL_MOUSEMOTION,Sdl.SDL_MOUSEBUTTONDOWN,Sdl.SDL_ ...

  8. VBA笔记(一)

    开启VBA编程环境--VBE 方法一:按<Alt+F11>组合建 方法二:查看代码 宏设置 当然启用宏的设置方式不同,宏的启动方式也不一样. 首先打开"office 按钮&quo ...

  9. C和指针 第十章 结构和联合 (一)

    结构体: 聚合数据类型是指,能够同时存储超过一个的单独数据,C语言中有两个聚合数据类型,数组和结构体.数组中储存的类型必须相同,元素通过下标和指针引用来访问的. 结构体也是一些值的集合,但是结构体中每 ...

  10. HDU 5023 A Corrupt Mayor's Performance Art 线段树区间更新+状态压缩

    Link:  http://acm.hdu.edu.cn/showproblem.php?pid=5023 #include <cstdio> #include <cstring&g ...