-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
73 lines (65 loc) · 1.86 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Url to QRCode</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
</head>
<style>
body {
width: 400px;
text-align: center;
padding-top: 5em;
display: flex;
justify-content: center;
flex-wrap: wrap;
margin: 0 auto;
height: auto;
}
#qrCode {
display: flex;
justify-content: center;
margin-top: 3em;
}
.green-btn {
background-color: chartreuse;
border-radius: 5px;
text-decoration: none;
}
.green-btn:hover {
background-color: rgb(182, 254, 110);
transform: scale(1.01);
}
</style>
<body>
<div class="form">
<input id="urlInput" type="url" placeholder="Enter URL" />
<button class="green-btn" id="generateButton">Generate QR Code</button>
</div>
<div id="qrCode"></div>
<script>
document
.getElementById('urlInput')
.addEventListener('keydown', function (event) {
if (event.key === 'Enter') {
event.preventDefault();
generateQRCode();
}
});
document
.getElementById('generateButton')
.addEventListener('click', generateQRCode);
function generateQRCode() {
let url = document.getElementById('urlInput').value;
let qrCodeElement = document.getElementById('qrCode');
qrCodeElement.innerHTML = ''; // Clear the previous QR code
new QRCode(qrCodeElement, {
text: url,
width: 200,
height: 200,
});
}
</script>
</body>
</html>