» » Use jquery.qrcode to generate two-dimensional code

 

Use jquery.qrcode to generate two-dimensional code

Author: bamboo06 on 28-10-2014, 01:57, views: 3380

1
Two-dimensional code applications have penetrated into living and working among us, you only need a mobile phone in front of the two-dimensional code "sweep swept away" to get the corresponding information to help us understand the business, shopping, viewing and so on. This article will introduce a two-dimensional code generation based on jquery plugin qrcode, calling the plug-in page will be able to generate the corresponding two-dimensional code.

qrcode actually realized by using jQuery graphics rendering, drawing support canvas (HTML5) and the table are two ways that you can get the latest code to https://github.com/jeromeetienne/jquery-qrcode.
How to use
1, first joined jquery library files and qrcode plugin page.
<script type="text/javascript" src="jquery.js"></script> 
<script type="text/javascript" src="jquery.qrcode.min.js"></script> 

2,adding the following code in the page where you want to display two-dimensional code:
<div id="code"></div> 

3, call qrcode plugin.
qrcode supports two ways canvas and table picture rendering, canvas default mode, the highest efficiency, of course, the browser supports html5. Direct call is as follows:
$('#code').qrcode("http://www.helloweba.com"); //any strings  

You can also call as follows:
$("#code").qrcode({ 
    render: "table", //table type
    width: 200, //width
    height:200, //height
    text: "www.goocode.net" //any content
}); 

This can generate a two-dimensional code in the page, you can use the phone, "sweep the" function to read the two-dimensional code information.
Chinese Recognition
When we tested does not recognize Chinese content found two-dimensional code, multi-information learned by looking, jquery-qrcode is the use charCodeAt () methods for encoding conversion. And this method will get its default Unicode encoding, if there is Chinese content before it is imperative to generate two-dimensional code string into UTF-8, and then generate a two-dimensional code. You can use the following function to convert Chinese string:
function toUtf8(str) {    
    var out, i, len, c;    
    out = "";    
    len = str.length;    
    for(i = 0; i < len; i++) {    
        c = str.charCodeAt(i);    
        if ((c >= 0x0001) && (c <= 0x007F)) {    
            out += str.charAt(i);    
        } else if (c > 0x07FF) {    
            out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));    
            out += String.fromCharCode(0x80 | ((c >>  6) & 0x3F));    
            out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));    
        } else {    
            out += String.fromCharCode(0xC0 | ((c >>  6) & 0x1F));    
            out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));    
        }    
    }    
    return out;    
} 

Example lists as follows:
var str = toUtf8("Chinese Charactors"); 
$('#code').qrcode(str); 

Category: Javascript

Dear visitor, you are browsing our website as Guest.
We strongly recommend you to register and login to view hidden contents.
<
  • 0 Comments
  • 0 Articles
27 April 2017 20:23

CesMamEbra

Reply
  • Group: Guests
  • –†Registered date: --
  • Status:
 
Il Cialis Non Fa Effetto viagra Cialis Lilly Gmbh Cialis Prezzo 2013 cialis Where Can I Purchase Viagra Online Priligy Riesgos buy viagra Cialis Valladolid Viagra Flughafen generic viagra Effet Levitra Stendra 100mg Where To Purchase cialis online Viagra Eqivalent Herbal Tablets Acquista Viagra In Italia Propecia Buy Cialis Levitra 10 Mg In Farmacia Cytotec Without Prescription cialis Buycialisonlinenowrx Cheap Mexican Pharmacy Neurontin viagra online prescription Canadian Pharmacy Meds Viagra Falschungen Nebenwirkungen accutane pharacy online Problemas De Propecia Pastilla Cialis Que Es viagra online prescription Etienne Buy Propecia Finasteride Online cialis How To Buy Levaquin Overseas Osu Cialis Costo viagra online Buy Celebrex In The Uk Viagra Lagerung cialis Levitra Bailler Find Doxycycline Best Website buy viagra Priligy Rezeptfrei Paypal Viagra Rezeptfrei Versandapotheken viagra cialis Omeprazole Clarithromycin Amoxicillin


Add comments

Name:*
E-Mail:
Comment:
Bold Italic Underline Strike | Align left Center Align right | Insert smilies Insert link URLInsert protected URL Select color | Add Hidden Text Insert Quote Convert selected text from selection to Cyrillic (Russian) alphabet Insert spoiler
Security Code: *