日期:2014-05-17  浏览次数:20607 次

HTML5 Notification桌面提醒功能,html5 教程
HTML5 Notification桌面提醒功能,html5 教程

<!DOCTYPE HTML>
<html>
<head
<meta charset="gbk">
<title>Creating OS notifications in HTML5</title>
</head>
<body>
<input type="button" value="验证授权" onclick="init();" />
<input type="button" value="弹出消息" onclick="notify();" />

const miao = 5;
function init(){
if (window.webkitNotifications) {
window.webkitNotifications.requestPermission();
}
}
function notify() {
if (window.webkitNotifications.checkPermission() == 0) {
var popup = window.webkitNotifications.createNotification("zencart.me.png", "http://zencart.me", " http://zencart.me/archives/905");
popup.ondisplay=(function(event){
setTimeout(function() {
event.currentTarget.cancel();
}, miao * 3000);
});
popup.show();
}else{
window.webkitNotifications.requestPermission();
}
}
HTML5 Notification桌面提醒功能,html5 教程 http://zencart.me/archives/905