forked from bluemarvin/html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vibration.html
30 lines (30 loc) · 1.02 KB
/
vibration.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
<title>The Vibration API Example</title>
<script>
window.addEventListener("load", function() {
if (window.navigator.vibrate) {
document.querySelector("#supported").textContent = "Yes";
document.querySelector("#vibrateOnce").addEventListener("click", function() {
window.navigator.vibrate(1000);
}, false);
document.querySelector("#vibrateThrice").addEventListener("click", function() {
window.navigator.vibrate([1000, 1000, 2000, 1000, 3000]);
}, false);
} else {
document.querySelector("#supported").textContent = "No";
}
}, false);
</script>
</head>
<body>
Vibration API Supported: <span id="supported"></span>
<br />
<input id="vibrateOnce" type="button" value="Vibrate Once" />
<input id="vibrateThrice" type="button" value="Vibrate Thrice" />
</body>
</html>