Skip to content

Instantly share code, notes, and snippets.

@bharathjinka09
Created September 30, 2021 14:30
Show Gist options
  • Save bharathjinka09/07f4a7076cc851726724e35ba5c26b1e to your computer and use it in GitHub Desktop.
Save bharathjinka09/07f4a7076cc851726724e35ba5c26b1e to your computer and use it in GitHub Desktop.
Cross-browser QRCode
<input id="text" type="text" value="https://hogangnono.com" style="width:80%" /><br />
<div id="qrcode"></div>
var qrcode = new QRCode("qrcode");
function makeCode () {
var elText = document.getElementById("text");
if (!elText.value) {
//alert("Input a text");
elText.focus();
return;
}
qrcode.makeCode(elText.value);
}
makeCode();
$("#text").
on("blur", function () {
makeCode();
}).
on("keydown", function (e) {
if (e.keyCode == 13) {
makeCode();
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/davidshimjs/qrcodejs/gh-pages/qrcode.min.js"></script>
#qrcode {
width:160px;
height:160px;
margin-top:15px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment