码迷,mamicode.com
首页 > Web开发 > 详细

JS生成二维码

时间:2016-04-13 18:22:54      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html>
    <head>
        <script src="jquery-2.0.3.js" type="text/javascript"></script>
        <script src="qr.js" type="text/javascript"></script>
        <script type="text/javascript">
        var qr_coder = null;
            $(document).ready(function(){
                qr_coder = new QRCoder($(#qr_container));
                $(#qr_gen).click(function() 
                {
                    $(#qr_container).html("");
                    
                    var watch_start=new Date();
                    qr_coder.setMode(1);
                    qr_coder.draw(
                                $(#qr_link).val(), 
                                $("[name=‘qr_capacity‘]:checked").val(),
                                icon.png,
                                function(data)
                                {
                                    var watch_end=new Date();
                                    console.log("cost:"+(watch_end-watch_start)+"ms");

                                });
                });
            });
        </script>
    
    </head>
    <body>
        <h1>QR CODER</h1>
        <div style="margin:auto; position:relative; margin-left: 50%; left: -250px; width:500px;">
            <label for="qr_link">URL:</label>
            <input id="qr_link" type="text" value="http://you.ctrip.com" style="width:350px;" /> 
            <button id="qr_gen" value="Generate">生成二维码</button> <br />
            <div style="display:none">
                <input id="qr_capacity_l" name="qr_capacity" type="radio" value="L"/> <label for="qr_capacity_l">7%</label>
                <input id="qr_capacity_m" name="qr_capacity" type="radio" value="M"/> <label for="qr_capacity_m">15%</label>
                <input id="qr_capacity_q" name="qr_capacity" type="radio" value="Q"/> <label for="qr_capacity_q">25%</label>
                <input id="qr_capacity_h" name="qr_capacity" type="radio" value="H" checked/> <label for="qr_capacity_h">30%</label>
            </div>
        </div>
        <div id="qr_container" style="margin:auto; position:relative;"></div>
    </body>
</html>

 

需引入qr.js

地址:http://pan.baidu.com/s/1csiYVs

JS生成二维码

标签:

原文地址:http://www.cnblogs.com/carol1987/p/5388001.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!