-
Notifications
You must be signed in to change notification settings - Fork 18
/
index.html
90 lines (83 loc) · 2.78 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Demo: The Easiest Way To Show Browser Notifications</title>
<style>
body {
font-family: sans-serif;
color: #333435;
line-height: 1.5;
text-align: center;
padding: 50px;
}
h1 {
max-width: 400px;
line-height: 1.4;
margin: 0 auto 40px;
text-align: center;
color: #21629b;
font-size: 29px;
}
p {
font-size: 16px;
margin: 15px auto;
text-align: center;
max-width: 430px;
}
a, a:visited, a:hover {
text-decoration: none;
color: #267ac3;
}
#demo-btn {
padding: 18px;
color: #fff;
background-color: #1E88E5;
outline: 0;
border: 0;
font-size: 16px;
text-transform: uppercase;
cursor: pointer;
opacity: 0.9;
border-radius: 4px;
margin: 45px auto;
display: block;
font-weight: bold;
}
#demo-btn:hover {
opacity: 1;
}
p.footer {
color: #889098;
font-size: 15px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="container">
<h1>The Easiest Way To Show Browser Notifications</h1>
<p>This simple demo aims to show you the easiest possible way to display web notifications using <a href="https://github.com/Nickersoft/push.js" target="_blank">Push.js</a>.</p>
<button id="demo-btn">Show notification</button>
<p class="footer">To read the full article go to <a href="http://tutorialzine.com/2017/01/the-easiest-way-to-show-browser-notifications">tutorialzine.com</a></p>
<p class="footer">The source code for this demo is available on <a href="https://github.com/tutorialzine/web-notifications-demo">GitHub</a></p>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/push.js/0.0.11/push.min.js"></script>
<script>
Push.Permission.request();
document.getElementById('demo-btn').onclick = function () {
Push.create('Hi there!', {
body: 'This is a notification.',
icon: 'icon.png',
timeout: 8000, // Timeout before notification closes automatically.
vibrate: [100, 100, 100], // An array of vibration pulses for mobile devices.
onClick: function() {
// Callback for when the notification is clicked.
console.log(this);
}
});
};
</script>
</html>