Qrcode.js
Qrcode.js is dependent on JS to generate two-dimensional code. Mainly by obtaining the tag of the DOM, and then drawn by Html5canvas, not dependent on JQ
Get Qrcode.js
- Github-page:qrcode.js
Github-repository
- There are tar.gz packages and zip packages.
Introduction and Usageintroduced
- As long as
it is introduced in, JQ is not dependent and can be replaced by other versions of JQ (other content useful to JQ, such as selector acquisition)
<script type="text/javascript" src="qrcode.js"></script>
Basic UsageGet the block, call the default method directly (enter the generated string to generate the QR code)
<Div Id="QRCode"></Div><script type = "text/javascript" > new qrcode (document. Getelementbyid "QRCode" "Https//blog.csdn.net/crper" </script< span class= "tag" >>
Advanced UsageQRCode supports the following parameters:
- Width (wide)
- Height (altitude)
- Colordark (background color)
- Colorlight (front view)
- Correctlevel (fault tolerance level, support L,m,h) Low/middle/high
VarQRCode= New QRCode("Test", {Text: "Https//blog.csdn.net/crper",Width: 400,Height: 400,Colordark: "#000000", Colorlight : < span class= "str" > "#ffffff" , Correctlevel : qrcode. Correctlevel. Hqrcode.//clear qr code qrcode. "http://naver.com" //generate another QR code
Online generation functionThis function is to get the ID of text, to determine whether the content is empty, the popup window is empty, and not empty to generate a two-dimensional code
function Makecode () { VarEltext=Document.getElementById("Text"); If (! Eltext. Value { Alert ( "Please enter the QR code content you want to generate!" Eltext.return;} Qrcode. (eltext. Value}makecode ();
Trigger by calling Blur and KeyDown, generate a QR code when you click out of focus, or enter content and press ENTER
$("#text").On("Blur", function () {Makecode(); }).On( "KeyDown" , function (e) { if (e.< Span class= "PLN" >keycode == 13< Span class= "pun" >) { Makecode (); } });
Practical Small Example<! DOCTYPE html><Html> <Head> <Title>Demo</Title> <Meta Http-equiv="Content-type" Content="Text/html;charset=utf-8"> <Meta Name="Viewport" Content="Width=device-width,initial-scale=1,user-scalable=no" /> <!--referencing local script files-- <Script Type="Text/javascript" Src="Jquery.min.js"></Script> <Script Type="Text/javascript" Src="Qrcode.js"></Script> <Style> #qrcode { Height: 300Px; Width: 300Px; Background: #eee; } Input { Height: 25Px; Line-Height: 25px; width: 300px;} </style>
browser Adaptation to support the following
PC |
Mobile |
Ie6~10 |
Mobile Safari |
Chrome |
Android |
Firefox |
Windows Mobile |
Safari |
|
Opera |
|
Follow the agreementHttp://www.bubuko.com/infodetail-825496.html
Qrcodejs generate a QR code