forked from mkiol/GNotifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
executable file
·55 lines (47 loc) · 2.18 KB
/
test.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
<html>
<head>
<title>Notifications test</title>
<script>
function test1() {
var notification = navigator.mozNotification.createNotification("Test", "Mozilla deprecated API", "https://developer.cdn.mozilla.net/media/img/mdn-logo-sm.png");
notification.show();
}
function test2() {
var notification = new Notification("Test",{body: "Standard API", icon: "https://www.w3.org/Icons/w3c_home"});
notification.addEventListener("click",function(){alert("Click!");},false);
}
function test4() {
var notification = new Notification("Test",{body: "<b>Standard</b> <span style='color:red'>API</span>", icon: "https://www.w3.org/Icons/w3c_home"});
notification.addEventListener("click",function(){alert("Click!");},false);
}
function test5() {
var notification = new Notification("Test",{body: "Standard API <img src='https://www.w3.org/Icons/w3c_home' alt='test image'/>", icon: "https://www.w3.org/Icons/w3c_home"});
notification.addEventListener("click",function(){alert("Click!");},false);
}
function test6() {
var notification = new Notification("Test",{body: "Standard API <input text='Test button' type='submit'/>", icon: "https://www.w3.org/Icons/w3c_home"});
notification.addEventListener("click",function(){alert("Click!");},false);
//notification.addEventListener("close",function(){alert("Close!");},false);
}
function test3() {
console.log(window.webkitNotifications.checkPermission());
if (window.webkitNotifications.checkPermission() == 0) {
var notification = window.webkitNotifications.createNotification("http://www.google.pl/intl/pl/chrome/assets/common/images/chrome_logo_2x.png", "Test", "Webkit API");
notification.show();
} else {
window.webkitNotifications.requestPermission();
}
}
</script>
</head>
<body>
<button onclick="test1()">Mozilla deprecated API</button><br/>
<button onclick="test3()">Webkit API</button><br/>
<br/>
<button onclick="test2()">Standard W3C API</button><br/>
<button onclick="test4()">Standard W3C API (simple html tags)</button><br/>
<button onclick="test5()">Standard W3C API (img tags)</button><br/>
<button onclick="test6()">Standard W3C API (button)</button><br/>
<br/>
</body>
</html>