Content Source: http://www.runoob.com/w3cnote/javascript-qrcodejs-library.html
Qrcode.js is a JavaScript library for generating two-dimensional code. This is done primarily by getting the tag of the DOM and drawing it through the HTML5 Canvas, without relying on any library. Basic Usage
<div id= "QRCode" ></div>
<script type= "Text/javascript" >
new QRCode ( document.getElementById ("QRCode"), "http://www.runoob.com"); Set up a link to generate a two-dimensional code
</script>
Or use some optional parameter settings:
var qrcode = new QRCode ("test", {
text: "Http://www.runoob.com",
width:128,
height:128,
colordark: "# 000000 ",
colorlight:" #ffffff ",
correctlevel:qrcode.correctlevel.h
});
Also we can use the following methods:
Qrcode.clear (); Clear code
qrcode.makecode ("http://www.w3cschool.cc");//Generate another two-dimensional code
Browser Support
Browsers that support the library are: ie6~10, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, and more. Instance Code HTML Code
<input id= "text" type= "text" value= "http://www.runoob.com"/><br/> <div id=
"QRCode" ></div >
CSS Code
#qrcode {
width:160px;
height:160px;
margin-top:15px;
}
JavaScript Code
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 = =) {
makecode ();
}
});
Try» Download Resources
QRCode Library and instance download:qrcodejs-04f46c6.zip
Github Address:Https://github.com/davidshimjs/qrcodejs