html
html
1
2
3
4
5
6
7
8
9
10
11
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<button id="button">vibrate</button>
<button onclick="stop()">stop</button>
<button onclick="pattern()">pattern</button>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
button{
background-color:red;
color:lightyellow;
width:200px;
height:60px;
}
body{
background-color:lightblue;
}
circle {
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
onload = entry,stop;
function entry(){
document
.getElementById("button")
.addEventListener("click",
click,
false
);
}
function click(){
var x = prompt ("enter duration (in seconds)");
vibrate (x)
}
function vibrate(x){
navigator.vibrate(x*1000)
}
function pattern(){
var patt = [500,250,500]
navigator.vibrate(patt)
}
function stop(){
navigator.vibrate(0);
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run