<html>
<head>
<title>桌面通知</title>
<meta name="description" content="实战Chrome浏览器桌面通知" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type='text/javascript'> //granted 允许 denied 拒绝 undefined 未定义 default 用户不操作
function getStatus()
{ return Notification.permission; } function init() {
if (!("Notification" in window)){
alert("您当前浏览器不支持该功能!\n建议使用猎豹、360等浏览器使用此功能");
$("#zmtz").removeAttr("checked");
}
else {
//申请授权
if (Notification.permission == null || Notification.permission == undefined)
window.webkitNotifications.requestPermission();
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
if (!('permission' in Notification))
Notification.permission = permission;
});
}
$("#zmtz").attr("checked","checked");
}
} function send(title,theBody,theIcon)
{ var options = {
body: theBody,
icon: theIcon
} if (!("Notification" in window)) { return ;
} else if (Notification.permission === "granted") {
// If it's okay let's create a notification
var notification = new Notification(title,options);
} // Otherwise, we need to ask the user for permission
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
// If the user accepts, let's create a notification
if (permission === "granted") {
var notification = new Notification(title,options);
}
});
} }
</script> </head>
<body> <div>
<input type="button" value="开启" onclick="javascript:init()">
通知内容:<input type="button" value="发喊单" onclick="javascript:send('您有一条新喊单','详细信息','1.png')">
<input type="button" value="获取状态" onclick="javascript:alert(getStatus())">
</div> </body>
</html>

web通知的更多相关文章

  1. 使用HTML5的Notification API制作web通知的教程(转)

    var notification=new Notification(‘Notification Title',{ body:'Your Message' }); 上面的代码构造了一个简陋的通知栏.构造 ...

  2. 浏览器开启web通知。

    https://www.cnblogs.com/xcsn/p/7767092.html

  3. QtWebkit2.2.0 HTML5.0支持情况

      Canvas: 支持element, 2d context以及文本 解析规则:支持 HTML5 tokenizer/tree building,  SVG in text/html, MathML ...

  4. 基于 websocket 实现的 im 实时通讯案例

    分享利用 redis 订阅与发布特性,巧妙的现实高性能im系统.为表诚意,先贴源码地址:https://github.com/2881099/im 下载源码后的运行方法: 运行环境:.NETCore ...

  5. PhoneGap_百度百科

    PhoneGap编辑 PhoneGap是一个用基于HTML,CSS和JavaScript的,创建移动跨平台移动应用程序的 快速开发平台.它使开发者能够利用iPhone,Android,Palm,Sym ...

  6. awesome-javascript

    一系列令人敬畏的浏览器端JavaScript库,资源和闪亮的东西. 令人敬畏的JavaScript 包管理员 装载机 捆扎机 测试框架 QA工具 MVC框架和库 基于节点的CMS框架 模板引擎 文章/ ...

  7. Chrome浏览器启动参数大全(命令行参数)

    前言 在开发Web项目当中,浏览器必不可少,而浏览器的启动参数可以帮我们实现很多功能. 常用参数 常用参数请参考下表. 序号 参数 说明 1 --allow-outdated-plugins 不停用过 ...

  8. 使用 XMPP 构建一个基于 web 的通知工具——转

    Inserting of file(使用 XMPP 构建一个基于 web 的通知工具.docx) failed. Please try again. http://www.ibm.com/develo ...

  9. HTML5桌面通知(Web Notifications)实例解析

    先上一段代码,ie不支持,Chrome.fireFox.Opera支持 <!DOCTYPE html> <html> <head> <meta http-eq ...

随机推荐

  1. android studio 工程设置项

    1.在<工程根目录>\build\generated文件夹中 存在 xxx.jar 这个文件是用来做单元测试用的,但该功能目前还处于实验阶段,不想用可以关了. 去掉勾后,clean一下工程 ...

  2. linux 下查看cpu是几核的

    几个cpu more /proc/cpuinfo |grep "physical id"|uniq|wc -l 每个cpu是几核(假设cpu配置相同) more /proc/cpu ...

  3. swift3 控件创建

    //MARK:- UIScrollView let scrollView = UIScrollView() scrollView.delegate = target scrollView.backgr ...

  4. 我是如何给discuz模板做语法高亮的

    本人一直做ASP.NET开发,近期接到任务要用Discuz开发一个社区,第一次接触PHP,PHP灵活的语法,天生的模块化,各种语法糖深深的震惊了我,我从内心深处感受到了PHP是最牛逼的语言!!! 好了 ...

  5. PHP在浏览器上跟踪调试的方法以及使用ChromePhp、FirePHP的简单介绍

    之前用ThinkPHP时发现有个 trace 函数可以跟踪调试,感觉很有意思,网上搜索了下类似的东西,发现了 ChromePhp ,以前没想过这样来调试 PHP 程序,感觉非常方便,很有用. Thin ...

  6. Let's DO IT !

    今天开始逐步自学计算机图形学. 慢慢成长.

  7. delphi const

    参考:http://www.cnblogs.com/tibetwolf/articles/1785744.html 1.const修饰可能会优化编译代码.关于这一点与编译器密切相关,由于变量被cons ...

  8. windows自带的线程池

    #define _CRT_SECURE_NO_WARNINGS #include "iostream" #include "windows.h" using n ...

  9. Javascript封装弹出框控件

    1.首先先定义好弹出框的HTML结构 <div class="g-dialog-contianer"> <div class="dialog-windo ...

  10. 防范CSRF(一)

    CSRF是跨网站伪造请求的缩写.大致的攻击流程是,黑客获得浏览器向服务器发送的请求,然后对请求进行修改,让服务器执行指定的操作. 防范方式可以使用微软提供的解决方案. View放置Html.AntiF ...