前端开发javascript 画二维码

安卓端开发是前端还是
安卓前端开发技术
安卓开发属于前端还是后端
<!DOCTYPE html>
<html xmlns=”http://www.w3.org/1999/xhtml”>
    <head>
        <meta charset=”utf-8″ />
        <title>画二维码模板</title>
    </head>
    <body>
        <div class=”container”>
            <a>请输入URL:</a
            ><input type=”url” id=”url” style=”width:300px;height:25px;” />
            <div
                id=”newQrcode”
                style=”height:160px;width:160px;border:1px solid #b6ff00;margin:10px;padding-top:10px;padding-left:10px;”
            ></div>
            <button id=”btnDrawCode”>画二维码</button>
        </div>
        <script src=”//cdn.bootcss.com/jquery/1.12.0/jquery.min.js”></script>
        <script src=”//cdn.bootcss.com/jquery.qrcode/1.0/jquery.qrcode.min.js”></script>
        <script>
            function utf16to8(str) {
                //二维码包含的内容,默认只支持英文内容,中文会乱码,通过utf16to8转码可支持中文
                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
            }
            $(‘#btnDrawCode’).click(function() {
                var url = $(‘#url’).val()
                url = url == ” ? ‘http://www.zhoou.com’ : url
                url = utf16to8(url)
                jquery(‘#newQrcode’).qrcode({
                    text: url, //设置二维码内容
                    width: 150, //设置宽度
                    height: 150, //设置高度
                    correctLevel: 0, //纠错等级,
                    render: ‘canvas’, //设置渲染方式
                    background: ‘#ffffff’, //背景颜色
                    foreground: ‘#000000’, //前景颜色
                })
            })
        </script>
    </body>
</html>
安卓前端开发职业
安卓前端开发岗位职责
安卓前端开发IDE
赞(0)
前端开发者 » 前端开发javascript 画二维码
64K

评论 抢沙发

评论前必须登录!