<!DOCTYPE html>
<html>
<head>
<title>Google 桌面通知</title>
</head>
<body>
<button onclick="notifyMe()">Notify me!</button>
<script type='text/javascript'>
function notifyMe() {
var title = "new message";
var options = {
body: "message content",
icon: "http://www.51sjk.com/Upload/Articles/1/0/321/321833_20220815175554923.png"
};
// Let's check if the browser supports notifications
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}
// Let's check whether notification permissions have already been granted
else if (Notification.permission === "granted") {
// If it's okay let's create a notification
var notification = new Notification(title, options);
notification.onshow = function() {
setTimeout(function() {
notification.close();
}, 3000);
};
}
// 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);
notification.onshow = function() {
setTimeout(function() {
notification.close();
}, 3000);
};
}
});
}
// At last, if the user has denied notifications, and you
// want to be respectful there is no need to bother them any more.
}
</script>
</body>
</html>
XHTMT|
HTML5|
CSS|
HTML DOM|
jQuery|
JSON|
AJAX|
LESS|
HTML|
Bootstrap|
Foundation|
AngularJS|
Ember.js|
TypeScript|
AngularJS2|
React|
jQuery UI|
jQuery EasyUI|
Node.js|
Highcharts|
Echarts|
Vue.js|
CoffeeScript|
Ext.js|
Meteor|
SASS|
Omi|
Markdown|
前端开发规范|
浏览器|
webpack|
JavaScript|
CSS3|
用户登录
还没有账号?立即注册
用户注册
投稿取消
| 文章分类: |
|
还能输入300字
上传中....
广州的段友互粉吧