zoukankan      html  css  js  c++  java
  • jquery.qrcode.js生成二维码

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="js/jquery.min.js"></script>
        <script src="js/jquery.qrcode.min.js"></script>
        <script>
    //        jQuery(function () {
    //            $("#qrcode").qrcode({
    //                render: "table", //table方式
    //                 200, //宽度
    //                height: 200, //高度
    //                text: "www.codesky.net" //任意内容
    //            });
     
     
            //        });
            function generateQRCode(rendermethod, picwidth, picheight, url) {
     
                $("#qrcode").qrcode({
                    render: rendermethod, //rendermethod, 渲染方式有table方式(IE兼容)和canvas方式
                     picwidth, //宽度 
                    height: picheight, //高度 
                    text: url, //内容 中文utf16to8(url),
                    typeNumber: -1, //计算模式
                    correctLevel: 2, //二维码纠错级别
                    background: "#ffffff", //背景颜色
                    foreground: "#000000"  //二维码颜色
     
                });
            }
            function init() {
                generateQRCode("table", 200, 200, "https://hao.360.cn/");
                var margin = ($("#qrcode").height() - $("#codeico").height()) / 2;
                $("#codeico").css("margin", margin);
            }
            //中文编码格式转换
            function utf16to8(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;
            }   
     
        </script>
     
        </script>
        <style type="text/css">
            #codeico{
                position:fixed;
                z-index:9999999;
                30px; 
                height:30px;
                background:url(images/text.png) no-repeat;
            }
        </style>
    </head>
    <body  onload="init()">
        <div id="qrcode">
            <div id="codeico"></div>
        </div>
     
    </body>
    </html>
    下载js地址:http://www.oschina.net/p/jquery-qrcode-js

  • 相关阅读:
    北京各银行收取的帐户管理费
    Windows Beta2 不能识别VMWare的声卡
    Windows Vista 不再支持.hlp文件了
    不是所有的x64下的VMWare都可以安装Windows Vista x64
    Delphi下操作PDF文件的控件
    DriverWorks的KPciConfiguration不支持x64平台的解决方法
    查找Windows文件来历的好方法
    在iSEDQuickPDF中如何输出带中文的PDF文件
    英语听力简单研究
    How To Use A Launchpad PPA (Add, Remove, Purge, Disable) In Ubuntu
  • 原文地址:https://www.cnblogs.com/ft-Pavilion/p/5341788.html
Copyright © 2011-2022 走看看