forked from mr-body/bookstoreHTML
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqrcode.html
More file actions
35 lines (31 loc) · 1.3 KB
/
qrcode.html
File metadata and controls
35 lines (31 loc) · 1.3 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exemplo QR Code</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js" integrity="sha512-CNgIRecGo7nphbeZ04Sc13ka07paqdeTu0WR1IM4kNcpmBAUSHSQX0FslNhTDadL4O5SAGapGt4FodqL8My0mA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head>
<body>
<!-- Input para inserir o texto -->
<label for="texto">Texto:</label>
<input type="text" id="texto" name="texto">
<button onclick="gerarQRCode()">Gerar QR Code</button>
<!-- Div onde o código QR será gerado -->
<div id="qrcode"></div>
<script>
function gerarQRCode() {
document.getElementById("qrcode").innerHTML = ""
// Obtendo o valor do input
var texto = document.getElementById("texto").value;
// Instanciando um objeto QRCode com a div onde o código será renderizado
var qrcode = new QRCode(document.getElementById("qrcode"), {
width: 200,
height: 200
});
// Chamando o método makeCode para gerar o QR Code com o texto inserido pelo usuário
qrcode.makeCode(texto);
}
</script>
</body>
</html>