Use jquery. qrcode to generate a color QR code instance and a jquery. qrcode instance.

Source: Internet
Author: User

Use jquery. qrcode to generate a color QR code instance and a jquery. qrcode instance.

Jquery. qrcode. js is a plug-in used to draw two-dimensional codes in the jquery class library. It is used to render two dimensional codes: canvas and table. (When jquery. qrcode. js sets the display mode to table, it will be deformed in the core webkit browser, such as chrome. note this .)

The following is the test code (color control is added. You can set the color values of four blocks. You must specify render as table .), The effect is as follows:

The Code is as follows:

<Html> 

Jquery-qrcode this library is using charCodeAt this method for encoding conversion, and this method will get its Unicode encoding by default, the general decoder is using UTF-8, ISO-8859-1 and other methods, english is no problem, if it is Chinese, under normal circumstances Unicode is UTF-16 implementation, length 2 bits, and UTF-8 encoding is 3 bits, so the codec of the QR code does not match.
 
Solution: Convert the string into a UTF-8 before the QR code, the specific code as above utf16to8 Function


Which QR code generator is used for this QR code?

I will scan for a piece of software, whether you want to provide functions or be beautiful, and I will do this for you for free.
 
Jqueryqrcodeminjs is used to generate a QR code. A js error occurs when a LAN ip address is used for access. The object does not support the getcontext () method or attribute.

The security mechanism of the browser prevents scripts from running locally.
 

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.