Qrcodejs generate two-dimensional code

Source: Internet
Author: User

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 Usage

Get 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 Usage

QRCode 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 function

This 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 agreement

Http://www.bubuko.com/infodetail-825496.html

Qrcodejs generate a QR code

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.