<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. spark yarn任务的executor 无故 timeout之原因分析

    问题: 用  spark-submit --master yarn --deploy-mode cluster --driver-memory 2G --num-executors 6 --execu ...

  2. Android中设定EditText的输入长度

    方法一:可以在layout xml中加上属性android:maxLength 比如: <EditText         android:id="@+id/editTextShow& ...

  3. for循环执行步骤

    for循环的具体步骤: for(var i=0;i<5;i++){ alert(1); } 第一步--->初始化i(初始化只在for循环中执行一次); 第二步--->执行条件i< ...

  4. hdu1027

    #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const ...

  5. Python Data Visualization Cookbook 2.9.2

    import numpy as np import matplotlib.pyplot as plt def is_outlier(points, threshold=3.5): if len(poi ...

  6. c++ 随手记

    强类型的理解 先定义一些基础概念 Program Errors trapped errors.导致程序终止执行,如除0,Java中数组越界访问 untrapped errors. 出错后继续执行,但可 ...

  7. bootstrap的总结1 - 网格系统

    1.Bootstrap 网格系统 1)下表总结了 Bootstrap 网格系统如何跨多个设备工作: 2)Bootstrap 网格的基本结构 <div class="container& ...

  8. iosAPP打包上架xcode中Archive提交成功以后,不提示构建版本问题

    最近在项目更新时遇到Archive提交到开发者中心成功后,一直不提示构建版本信息,可能导致的原因是由于ios10以后对于APP中调用手机相册或摄像头麦克风时需要配置plist文件,配置如下内容或许会解 ...

  9. 使用jquery.validate.js插件进行表单里控件的验证

    jsp中具体实现的代码: <%@ page language="java" contentType="text/html; charset=UTF-8" ...

  10. Python编程工具IDLE快捷键

    IDLE编辑器快捷键 自动补全代码        Alt+/(查找编辑器内已经写过的代码来补全) 补全提示              Ctrl+Shift+space(默认与输入法冲突,修改之) (方 ...