-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnotification.html
34 lines (29 loc) · 907 Bytes
/
notification.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<button onclick="calculate()">calculate</button>
<script type="text/javascript">
window.onload = function () {
if (window.Notification) {
Notification.requestPermission();
}
};
function calculate() {
notify();
}
function notify() {
var notification = new Notification("Notification title", {
icon: "http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png",
body: "Notification text",
});
notification.onclick = function () {
window.open("http://google.com");
};
}
</script>
</body>
</html>