Qrcode.js use JS two-dimensional code generator __JS

Source: Internet
Author: User
Tags generator

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.