-
Notifications
You must be signed in to change notification settings - Fork 22
/
check.html
118 lines (100 loc) · 3.48 KB
/
check.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<html>
<head>
<meta charset="utf-8">
<script src="notify.js"></script>
<script>
function support() {
if(window.Notifier.HasSupport()) {
alert("你的浏览器支持桌面通知功能!");
} else {
alert("你的浏览器不支持桌面通知同能,请你使用chrome浏览器!");
}
}
function isGetPermission() {
if(window.Notifier.IsGetPermission()) {
alert("网站已经获取浏览器允许发送桌面通知权限!");
} else {
alert("需要获取浏览器允许发送桌面通知权限 !");
}
}
function disable(){
if(window.Notifier.Disable()) {
alert("网站被禁止发送桌面通知!");
} else {
alert("未被禁止发送桌面通知 !");
}
}
function requestPermission(){
window.Notifier.RequestPermission();
alert("已经发送请求,在可以获取权限的情况下会显示获取权限提示!");
}
var i = 0;
function notify() {
Notifier.Notify("", "通知"+i, "内容" + i++);
}
function notifyOnClick() {
Notifier.Notify("", "通知"+i, "内容" + i++, function () {
alert("通知被点击了!");
});
}
function fall() {
var obj = document.getElementById("model");
obj.innerHTML = "<strong>显示所有通知</strong>,但是chrome最多会在屏幕上显示三个,其他处于隐藏状态";
Notifier.ModelAll();
}
function update() {
var obj = document.getElementById("model");
obj.innerHTML = "<strong>更新模式</strong>,在上个通知位置显示本次通知";
Notifier.ModelUpdate();
}
function count() {
var obj = document.getElementById("model");
obj.innerHTML = "<strong>限制个数模式</strong>,默认是三个,你可以同ModelCount参数改变的,现在为2个";
Notifier.ModelCount(2);
}
function timeout() {
var obj = document.getElementById("model");
obj.innerHTML = "<strong>超过时间消失</strong>,现在设置5秒,";
Notifier.ModelTimeout(2);
}
function closePre() {
Notifier.ClosePre();
}
function closeLast() {
Notifier.CloseLast();
}
function closeAll() {
Notifier.CloseAll();
}
</script>
</script>
</head>
<body>
<div>
<p>准备操作</p>
<button onclick="support()"> 检查是否支持桌面通知功能</button>
<button onclick="isGetPermission()"> 是否可以显示桌面通知</button>
<button onclick="disable()">是否禁用本网站的显示桌面通知</button>
<button onclick="requestPermission()"> 尝试获取发送桌面通知权限 </button>
</div>
<div>
<p/>
<div id="model">显示所有通知,但是chrome最多会在屏幕上显示三个,其他处于隐藏状态</div>
<button onclick="notify()">发送通知</button>
<button onclick="notifyOnClick()">发送通知(onclick)</button>
</div>
<div>
<p>显示通知模式</p>
<button onclick="fall()">显示所有通知</button>
<button onclick="update()">更新通知</button>
<button onclick="count()">限制个数</button>
<button onclick="timeout()">过期自动关闭</button>
</div>
<div>
<p>关闭模式</p>
<button onclick="closePre()">关闭前一个</button>
<button onclick="closeLast()">关闭最早的</button>
<button onclick = "closeAll()">关闭所有</button>
</div>
</body>
</html>