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

HTML5Notification桌面提醒功能,html5教程

<!DOCTYPEHTML>

<html>

<head

<metacharset="gbk">

<title>CreatingOSnotificationsinHTML5</title>

</head>

<body>

<inputtype="button"value="验证授权"onclick="init();"/>

<inputtype="button"value="弹出消息"onclick="notify();"/>

constmiao=5;

functioninit(){

if(window.webkitNotifications){

window.webkitNotifications.requestPermission();

}

}

functionnotify(){

if(window.webkitNotifications.checkPermission()==0){

varpopup=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();

}

}

HTML5Notification桌面提醒功能,html5教程http://zencart.me/archives/905

相关推荐