Jquery. qrcode is a powerful jquery plug-in that can be used to render two-dimensional code graphics and generate two-dimensional code. it is very practical and can be referenced by friends. With the development of the mobile Internet, QR codes are now widely used. it is much more convenient to scan websites and add friends or other information.
A comprehensive evaluation system was developed in the early stage. Considering the gradual implementation of mobility, a long string of IP address user input is not convenient. with the help of the QR code, the user can pick up the mobile phone scan and directly enter the system.
Based on this application scenario, we have studied the implementation of the website QR code on the Internet, and summarized the following two methods:
1. use some QR codes to generate websites or QR Code generators to generate QR Code images and then link them to websites, such as QR Code cloud QR Code online generators.
Advantage: The development cost is zero, and diversified QR codes can be quickly realized;
Disadvantage: it is a little difficult to maintain the QR code.
2. generate a QR code image using java or. net code at the backend, and then reference the image on the website, such as qrcode and zxing.
Advantage: strong customization and quick batch generation
Disadvantage: heavyweight implementation method, high development cost for simple applications
3. on the front-end page, use javascript or other methods to generate a QR code (response? Such as jquery-qrcode.
Advantages: lightweight implementation, reducing image I/O and saving traffic
Disadvantage: it is not suitable for generating complex QR codes.
Of course, in actual application, these three implementation methods are not completely isolated. we can also combine the application based on the actual situation of the project to maximize efficiency and save costs.
In the evening, I chose a jquery-qrcode study.
Jquery-qrcode
Jquery-qrcode is a jquery plug-in that can generate QR code on the browser side. It is independent, with a minimum compression capacity of less than 4 kB and no image download requests. After this class library is introduced, you only need a line of code to easily add a QR code to the web page.
It is hosted on github: https://github.com/jeromeetienne/jquery-qrcode
Jquery-qrcode mainly contains two files:
1. qrcode. js: QR code algorithm implementation class
2. jquery. qrcode. js: Use jquery to encapsulate qrcode. js and generate a QR code by rendering canvas and table based on user parameters.
After compression, there is only one file jquery. qrcode. min. js.
Code implementation
Github provides detailed instructions and examples, so we will not explain them here.
However, to facilitate future use, I will reorganize a piece of code based on my experiences on the Internet.
The jquery-qrcode.html code is as follows:
Generate a QR code using jquery-qrcode