web通知
<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通知的更多相关文章
- 使用HTML5的Notification API制作web通知的教程(转)
var notification=new Notification(‘Notification Title',{ body:'Your Message' }); 上面的代码构造了一个简陋的通知栏.构造 ...
- 浏览器开启web通知。
https://www.cnblogs.com/xcsn/p/7767092.html
- QtWebkit2.2.0 HTML5.0支持情况
Canvas: 支持element, 2d context以及文本 解析规则:支持 HTML5 tokenizer/tree building, SVG in text/html, MathML ...
- 基于 websocket 实现的 im 实时通讯案例
分享利用 redis 订阅与发布特性,巧妙的现实高性能im系统.为表诚意,先贴源码地址:https://github.com/2881099/im 下载源码后的运行方法: 运行环境:.NETCore ...
- PhoneGap_百度百科
PhoneGap编辑 PhoneGap是一个用基于HTML,CSS和JavaScript的,创建移动跨平台移动应用程序的 快速开发平台.它使开发者能够利用iPhone,Android,Palm,Sym ...
- awesome-javascript
一系列令人敬畏的浏览器端JavaScript库,资源和闪亮的东西. 令人敬畏的JavaScript 包管理员 装载机 捆扎机 测试框架 QA工具 MVC框架和库 基于节点的CMS框架 模板引擎 文章/ ...
- Chrome浏览器启动参数大全(命令行参数)
前言 在开发Web项目当中,浏览器必不可少,而浏览器的启动参数可以帮我们实现很多功能. 常用参数 常用参数请参考下表. 序号 参数 说明 1 --allow-outdated-plugins 不停用过 ...
- 使用 XMPP 构建一个基于 web 的通知工具——转
Inserting of file(使用 XMPP 构建一个基于 web 的通知工具.docx) failed. Please try again. http://www.ibm.com/develo ...
- HTML5桌面通知(Web Notifications)实例解析
先上一段代码,ie不支持,Chrome.fireFox.Opera支持 <!DOCTYPE html> <html> <head> <meta http-eq ...
随机推荐
- 【android错误】bitmap size exceeds 32bits
使用图片缩放时遇到这么个问题: java.lang.IllegalArgumentException: bitmap size exceeds 32bits 后来一行行查代码,发现原来是 scale ...
- Jasper_style
(1) text field <style name="Header" forecolor="#FFFFFF" backcolor="#002D ...
- 如何查看centos系统版本
[root@LAMP1 config]# cat /proc/version Linux version 2.6.32-279.el6.x86_64 (mockbuild@c6b9.bsys.dev. ...
- iOS混合应用开发入门
原文出处: cocoacontrols 译文出处:魏志峰(@JeremyWei) 欢迎分享原创到伯乐头条 http://blog.jobbole.com/46554/ 介绍 上周(译者:原文成 ...
- Struts2中实现文件上传的功能
1.首先得配置一下Struts得配置文件struts-xml: <?xml version="1.0" encoding="UTF-8" ?> &l ...
- C#导出EXCEL的方法
/// using System; using System.Collections.Generic; using System.Text; using System.Data; using Syst ...
- Base algorithm
今天介绍几种常见的算法,在面试中或许能派上用场 1.字符串倒转 //Reverse a string public static string Reverse(string ori) { string ...
- Linux 图形系统界面 和 文本系统和界面切换
本着,有好轮子就不要乱造的原则 下面是原文连接,来自三石兄的博客 http://www.cnblogs.com/deepstone/p/3344430.html 1.默认开机进入文本模式 如果想让开机 ...
- Font-Awesome IIS下不显示问题
解决方法: 在IIS设置中添加一个IMME fileExtension: .woff mimeType:application/x-font-woff
- [Mark] KVM 虚拟化基本原理
X86 操作系统是设计在直接运行在裸硬件设备上的,因此它们自动认为它们完全占有计算机硬件.x86 架构提供四个特权级别给操作系统和应用程序来访问硬件. Ring 是指 CPU 的运行级别,Ring 0 ...