jQuery生成二维码

jQuery.qrcode

实例下载

jQuery生成二维码实例下载


  1.  

  2.   type="text/javascript" src="jquery-1.3.2.min.js">

  3.   type="text/javascript" src="jquery.qrcode-0.12.0.min.js">

  4.     type="text/javascript">

  5.    

  6.     $(function(){

  7.      $("#bcTarget").barcode("123456789", "codabar",{barWidth:2, barHeight:80});

  8.      //二维码

  9.      $("#two").qrcode({

  10.    "render": "div",

  11.    "size": 100,

  12.    "color": "#3a3",

  13.    "text": "http://liubo.club"

  14.      });

  15. });

  16.  

  17.    

  18.  

  19.  

  20. 二维码


  21. id="two">

  • jQuery生成二维码_第1张图片




    
    
    1.  
    2.     type="text/javascript" src="jquery-1.3.2.min.js">
    3.     type="text/javascript" src="jquery-barcode-2.0.1.js">
    4. type="text/javascript" src="jquery.qrcode-0.12.0.min.js">
    5.     type="text/javascript">
    6. //中文问题
    7.    function toUtf8(str) {      
    8.    var out, i, len, c;      
    9.    out = "";      
    10.    len = str.length;      
    11.    for(i = 0; i < len; i++) {      
    12.        c = str.charCodeAt(i);      
    13.        if ((c >= 0x0001) && (c <= 0x007F)) {      
    14.            out += str.charAt(i);      
    15.        } else if (c > 0x07FF) {      
    16.            out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));      
    17.            out += String.fromCharCode(0x80 | ((c >>  6) & 0x3F));      
    18.            out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));      
    19.        } else {      
    20.            out += String.fromCharCode(0xC0 | ((c >>  6) & 0x1F));      
    21.            out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));      
    22.        }      
    23.    }      
    24.    return out;      
    25. }  
    26.     $(function(){
    27.      $("#bcTarget").barcode("123456789", "codabar",{barWidth:2, barHeight:80});
    28.      //二维码
    29.      $("#two").qrcode({
    30.    "render": "div",
    31.    "size": 100,
    32.    "color": "#3a3",
    33.    "text": "http://liubo.club"
    34.      });
    35.      //生成条形码
    36.      $("#genid").click(function(){
    37.       var code = $("#orgcode").val();
    38.       $("#mycode").barcode(code, "codabar",{barWidth:2, barHeight:80});
    39.      });
    40.      //生成二维码
    41.       $("#twobtn").click(function(){
    42.       var qrcode = $("#twotext").val();
    43.       qrcode =toUtf8(qrcode);
    44.       $("#twoimg").qrcode({
    45.    "render": "div",
    46.    "size": 100,
    47.    "color": "#3a3",
    48.    "text": qrcode
    49.      });
    50.      });
    51. });
    52.  
    53.    
    54.  
    55.  
    56. 首先自动生成条形码 123456789
    57. id="bcTarget">
  • 输入要生成条形码的数字
  • type="text" id ="orgcode">
  • id="mycode">
  • type="button"  value="生成条形码" id="genid"/>

  • liubo.club 二维码

  • id="two">
  • 输入内容生成二维码
  • type="text" id="twotext"/>

  • type="button" value="生成二维码" id="twobtn"/>
  • id="twoimg">

  • jQuery生成二维码_第2张图片

    关于生成的选项


    Usage

    The syntax is very simple. Just use

    $(selector).qrcode(options);

    to append a new generated HTML element representing the QR code to the selected elements. If the selected element already is a canvas element, then the QR code is drawn onto it.

    Options

    The available options and their default values are:

    {
        // render method: 'canvas', 'image' or 'div'    render: 'canvas',
    
        // version range somewhere in 1 .. 40    minVersion: 1,
        maxVersion: 40,
    
        // error correction level: 'L', 'M', 'Q' or 'H'    ecLevel: 'L',
    
        // offset in pixel if drawn onto existing canvas    left: 0,
        top: 0,
    
        // size in pixel    size: 200,
    
        // code color or image element    fill: '#000',
    
        // background color or image element, null for transparent background    background: null,
    
        // content    text: 'no text',
    
        // corner radius relative to module width: 0.0 .. 0.5    radius: 0,
    
        // quiet zone in modules    quiet: 0,
    
        // modes    // 0: normal    // 1: label strip    // 2: label box    // 3: image strip    // 4: image box    mode: 0,
    
        mSize: 0.1,
        mPosX: 0.5,
        mPosY: 0.5,
    
        label: 'no label',
        fontname: 'sans',
        fontcolor: '#000',
    
        image: null}





    你可能感兴趣的:(javascript,二维码,javascript,二维码)