Home>Article>Web Front-end> How to use jquery to generate a QR code with a logo in the middle? (with code)

How to use jquery to generate a QR code with a logo in the middle? (with code)

yulia
yulia Original
2018-09-13 16:34:01 2085browse

jquery.qrcode.js is a jquery plug-in that can generate matrix QR code QRCode on the client. It can be used to easily generate 2D barcodes on the page. This plug-in can be used independently and is relatively small in size, less than 4kb after gzip compression. Because it is a barcode generated directly on the client, there is no image downloading process and it can be generated quickly. It is encapsulated based on a multi-language class library and does not rely on other additional services.

Benefits: The benefit of using jquery-qrcode is that there is no need to generate redundant QR code images on the server side. The QR code is directly generated on the client side through JavaScript, effectively reducing bandwidth and maintenance costs.

First of all, you can take a look at the jquery.qrcode.js official website. There are also examples on the official website. However, jquery.qrcode.js on the official website does not support Chinese. Without further ado, let’s get started now. The qrcode.js file on the official website does not implement Chinese support and the addition of LOGO. Now we have modified this file to jquery.qrcode.js file. In addition, a file for transcoding Chinese is also needed, which is utf.js. Then the utf16to8(str) method of the utf.js file is called in the jquery.qrcode.js file to transcode the Chinese.

The following is an example I wrote. The js files required for this example are jquery.qrcode.js and utf.js as well as jquery-1.8.0.js. There is also a LOGO picture that can be clicked to download. The called jsp code is as follows:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>     该二维码支持中文和LOGO     

该二维码支持中文和LOGO

The above is the detailed content of How to use jquery to generate a QR code with a logo in the middle? (with code). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn