• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com专业计算机教程网站
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure
您的位置:首页 > 网页设计 >html5 > 什么是Notifications?HTML5 Notifications桌面提醒

什么是Notifications?HTML5 Notifications桌面提醒

作者:匿名 字体:[增加 减小] 来源:互联网 时间:2018-12-03

本文主要包含Notifications,HTML5等相关知识,匿名希望在学习及工作中可以帮助到您

Notifications是HTML5的一个新特性~ 可以看看360电脑抢票,也是用Notifications提示的~,下面小编写了一个HTML5 Notifications桌面提醒,还是挺不错的哦!<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8">
<title>HTML5 - Notifications</title>
<script>
//判断浏览器是否支持Notifications
function supported(){
	if(window.webkitNotifications){
		alert('浏览器支持Notifications');
	} else {
		alert('浏览器不支持Notifications');
	}
}

//请求桌面通知权限
function requestPermission() {
	window.webkitNotifications.requestPermission();
}

//获取请求权限状态
function checkPermission() {
	switch (window.webkitNotifications.checkPermission()) {
		case 0:alert('用户已允许显示桌面通知');break;
		case 1:alert('用户还没有允许或拒绝显示桌面通知');break;
		case 2:alert('用户已拒绝显示桌面通知');break;
	}
}

//创建文本消息
function textMsg(){
	var icon = 'logo.png';
	var title = '阿鹏\'s BLOG';
	var body =  'http://www.1990c.com';
	var popup = window.webkitNotifications.createNotification(icon, title, body);

	popup.ondisplay = function(event) {
		setTimeout(function() {
			event.currentTarget.cancel();
		}, 5000);
	}

	popup.show();
}

//创建HTML消息
function htmlMsg(){
	var popup = window.webkitNotifications.createHTMLNotification('msg.html');

	popup.ondisplay = function(event) {
		setTimeout(function() {
			event.currentTarget.cancel();
		}, 5000);
	}

	popup.show();
}
</script>
</head>

<body>
<input type="button" value="是否支持桌面提醒" onclick="supported();"/>
<input type="button" value="请求权限" onclick="requestPermission();"/>
<input type="button" value="请求权限状态" onclick="checkPermission();"/>
<input type="button" value="显示文本消息" onclick="textMsg();"/>
<input type="button" value="显示HTML消息" onclick="htmlMsg();"/>
</body>
</html>

以上就是什么是Notifications?HTML5 Notifications桌面提醒的详细内容,更多请关注微课江湖其它相关文章!

您可能想查找下面的文章:

  • html5桌面通知(Web Notifications)实例解析
  • 什么是Notifications?HTML5 Notifications桌面提醒
  • 基于HTML5 Notifications API的消息通知插件
  • HTML5新特性之WebNotifications
  • html5桌面通知(Web Notifications)实例解析_html5教程技巧

相关文章

  • 2018-12-03在HTML5爆发的年代Andorid开发APP的需求量是不是会慢慢下沉,开发者需求慢慢饱和?
  • 2017-08-06H5新属性audio音频和video视频的控制详解(推荐)
  • 2018-12-03使用HTML5 Canvas绘制直线或折线等线条的方法讲解_html5教程技巧
  • 2018-12-03你必须知道的28个HTML5特征、窍门和技术
  • 2018-12-03HTML5标准学习-编码详解
  • 2018-12-03H5手机端图片上传插件代码
  • 2018-12-03Html5新标签datalist相关用法介绍
  • 2017-08-06浅谈HTML5 defer和async的区别
  • 2018-12-03html5 video标签屏蔽右键视频另存为的js代码_html5教程技巧
  • 2018-12-0320个大大节省你时间的HTML5开发工具

文章分类

  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure

最近更新的内容

    • 六种常见的HTML5写法误用
    • HTML5 canvas基本绘图之绘制五角星
    • HTML5/CSS3实现漂亮的分步骤注册登录表单的示例代码分享
    • HTML5的classList属性操作CSS类的使用详解
    • HTML5的音频和JQUERY的全屏幻灯片
    • 详解HTML5中的拖放事件(Drag 和 drop)
    • HTML5学习笔记简明版(7):新增属性(2)
    • HTML5 Canvas像素处理常用接口
    • 响应式网页如何使用?总结响应式网页实例用法
    • 详解HTML5中rel属性的prefetch预加载功能使用

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有