-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqrcode.html
31 lines (30 loc) · 892 Bytes
/
qrcode.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
<!DOCTYPE html>
<html>
<head>
<title>Instascan</title>
<script type="text/javascript" src="instascan.min.js"></script>
</head>
<body>
<video id="preview"></video>
<p id="a"></p>
<script type="text/javascript">
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
scanner.addListener('scan', function (content) {
alert(content);
console.log(content);
});
Instascan.Camera.getCameras().then(function (cameras) {
document.getElementById('a').innerText = cameras.length;
if (cameras.length > 0) {
scanner.start(cameras[0]);
} else {
console.error('No cameras found.');
}
}).catch(function (e) {
document.getElementById('a').innerText = e;
alert(e);
console.error(e);
});
</script>
</body>
</html>