Use jquery.qrcode.js to generate QR code plug-in
QR code applications have penetrated into our lives and work. You only need to "scan" the QR code with your mobile phone to get the corresponding information, which is convenient for us to understand merchants, shop, watch movies, etc. . This article will introduce a jquery-based QR code generation plug-in qrcode. Calling this plug-in on the page can generate the corresponding QR code.
1.qrcode actually uses jQuery to achieve graphics rendering and drawing, supporting canvas (HTML5) and table.
github source code address: https:/ /github.com/jeromeetienne/jquery-qrcode
Parameter description:
render : "canvas",//Set the rendering method
width : 256, / /Set width
height : 256, //Set height
typeNumber : -1, //Calculation mode
correctLevel : QRErrorCorrectLevel.H,//Error correction level
background : "#ffffff", //Background color : "#000000" //Foreground color
2. Usage example:
plug-in Quote:
<script src="../Js/jquery-1.11.3.min.js"></script> <script src="../Js/jquery-qrcode-master/jquery.qrcode.min.js"></script>
Simple example 1:
<div id="code"></div> <script> //任意字符串 生成二维码 //默认使用Canvas画图 $('#code').qrcode('http://blog.csdn.net/u011127019'); </script>
Simple example 2:
<div id="code"></div> <script> //table 模式兼容 IE低版本 $('#code').qrcode({ render: 'table', width: 100, height: 100, text: 'http://blog.csdn.net/u011127019' }); </script>
Simple example 3 (Chinese support):
When we tested it, we found that it could not be recognized For the QR code of Chinese content, we learned from various sources that jquery-qrcode uses the charCodeAt() method for encoding conversion. This method will obtain its Unicode encoding by default. If there is Chinese content, the string must be converted to UTF-8 before generating the QR code, and then the QR code will be generated.
<div id="code"></div> <script> //如果内容中有中文,在生成二维码钱就要把字符串转换成utf-8 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; } $('#code').qrcode({ text: toUtf8('我是tianma'), width: 150, height: 150 }); //就目前 微信/支付宝等 不识别其他颜色的二维码 $('#code').qrcode({ text: toUtf8('我是tianma'), width: 150, height: 150, background: '#f00', foreground: '#0f0' }); </script>
Example 4:
//text 属性的值长度不能太长,最大字节数 10208 //text 字符串太长 微信/支付宝等扫一扫无法识别,微博识别内容更多 //微博扫一扫:大约200 字以内,微信扫一扫:大约 160字以内,支付宝扫一扫:大约130字符以内 $('#code').qrcode({ text: toUtf8('SignalR 是 ASP.NET 团队正在开发的一个 Microsoft .NET Framework 库和 jQuery 插件,可能包括在以后版本的 ASP.NET 平台中。 它提供了一些前景极为光明的功能,而这些功能正是,并且是越来越多的,当前不曾具有的,'), width: 150, height: 150 });
I hope this article will be helpful to you, use jquery.qrcode. This concludes the introduction to the content of the js-generated QR code plug-in. I hope you will continue to pay attention to our website!
For more articles related to using jquery.qrcode.js to generate QR code plug-ins, please pay attention to the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

How to merge array elements with the same ID into one object in JavaScript? When processing data, we often encounter the need to have the same ID...

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

In-depth discussion of the root causes of the difference in console.log output. This article will analyze the differences in the output results of console.log function in a piece of code and explain the reasons behind it. �...

Discussion on the realization of parallax scrolling and element animation effects in this article will explore how to achieve similar to Shiseido official website (https://www.shiseido.co.jp/sb/wonderland/)...

JavaScript can be run in PowerPoint, and can be implemented by calling external JavaScript files or embedding HTML files through VBA. 1. To use VBA to call JavaScript files, you need to enable macros and have VBA programming knowledge. 2. Embed HTML files containing JavaScript, which are simple and easy to use but are subject to security restrictions. Advantages include extended functions and flexibility, while disadvantages involve security, compatibility and complexity. In practice, attention should be paid to security, compatibility, performance and user experience.

Learning JavaScript is not difficult, but it is challenging. 1) Understand basic concepts such as variables, data types, functions, etc. 2) Master asynchronous programming and implement it through event loops. 3) Use DOM operations and Promise to handle asynchronous requests. 4) Avoid common mistakes and use debugging techniques. 5) Optimize performance and follow best practices.
