Skip to content

Instantly share code, notes, and snippets.

@Jignesh-Darji
Created April 9, 2018 09:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jignesh-Darji/8f4d7a90a10a74ec355ddebbe4a30bfc to your computer and use it in GitHub Desktop.
Save Jignesh-Darji/8f4d7a90a10a74ec355ddebbe4a30bfc to your computer and use it in GitHub Desktop.
QR Code Scanner Using HTML
<html>
<head>
<style>
body, input {font-size:14pt}
input, label {vertical-align:middle}
.qrcode-text {padding-right:1.7em; margin-right:0}
.qrcode-text-btn {display:inline-block; background:url('http://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2017/07/1499401426qr_icon.svg') 50% 50% no-repeat; height:1em; width:1.7em; margin-left:-1.7em; cursor:pointer}
.qrcode-text-btn > input[type=file] {position:absolute; overflow:hidden; width:1px; height:1px; opacity:0}
</style>
</head>
<body>
<input type=text size=16 placeholder="Tracking Code" class=qrcode-text><label class=qrcode-text-btn><input type=file accept="image/*" capture=environment onclick="return showQRIntro();" onchange="openQRCamera(this);" tabindex=-1></label>
<input type=button value="Go" disabled>
<script>
function openQRCamera(node) {
var reader = new FileReader();
reader.onload = function() {
node.value = "";
qrcode.callback = function(res) {
if(res instanceof Error) {
alert("No QR code found. Please make sure the QR code is within the camera's frame and try again.");
} else {
node.parentNode.previousElementSibling.value = res;
}
};
qrcode.decode(reader.result);
};
reader.readAsDataURL(node.files[0]);
}
function showQRIntro() {
return confirm("Use your camera to take a picture of a QR code.");
}
</script>
</body>
</html>
@jerosoler
Copy link

The librariy missing:

https://dmla.github.io/jsqrcode/src/qr_packed.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment