来源:自学PHP网 时间:2015-04-14 14:50 作者: 阅读:次
[导读] [html] !DOCTYPE html html head title桌面通知Notification /title meta http-equiv=Content-Type content=text/html; charset=utf-8 / script /script /h......
[html]
<!DOCTYPE html>
<html>
<head>
<title>桌面通知Notification </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
</script>
</head>
<body>
<input type="button" value="测试桌面通知" onclick = "checkPermissionAndShow()" />
<script>
window.Notifications = window.Notifications || window.webkitNotifications;
function checkPermissionAndShow(){
var perLel = window.Notifications.checkPermission();
if(perLel == 0){
console.log('已授权...');
showNotification();
}else if(perLel ==1){
console.log('待授权...');
window.Notifications.requestPermission(checkPermissionAndShow);
}else{
console.log('已禁止...');
}
}
function showNotification(){
var newNotification = Notifications.createNotification(
'http://avatar.csdn.net/4/5/3/1_qyf_5445.jpg',
'桌面通知',
'桌面通知 示例');
newNotification.show();
}
</script>
</body>
</html>
|
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com