Le plus simple pour créer un QR Code en JavaScript est d'utiliser l'API fournie par Google. Elle est gratuite et ne nécessite aucune inscription.
Voici comment créer un QR Code en JavaScript avec l'API de Google :
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Comment créer un QR Code en JavaScript ?</title>
</head>
<body>
<img src="https://chart.googleapis.com/chart?cht=qr&chl=https://www.1formatik.fr&chs=200x200&chld=L|0" id="qrcode">
<br>
<input type="text" size="60" id="url" placeholder="Contenu du QR Code" />
<button type="button" onclick="creerQRC();">Créer le QR Code</button>
<script>
function creerQRC() {
var url = document.getElementById("url").value;
var qrcode = 'https://chart.googleapis.com/chart?cht=qr&chl=' + encodeURIComponent(url) + '&chs=200x200&choe=UTF-8&chld=L|0';
document.getElementById("qrcode").src = qrcode;
}
</script>
</body>
</html>