Javascript產生二維碼(QR)

來源:互聯網
上載者:User

 <!DOCTYPE html><html>    <head>        <script src="./jquery-1.11.1.min.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("generating");                                        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">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>複製代碼在IE6,7,8,9,10,Firefox,Chrome中測試通過。 如果對於實現細節感興趣,下面我來詳細說明如何?。 一、參考文檔 在開始之前,需要準備一些參考文檔來協助理解: 1, QR 國際標準 ISO/IEC 18004. (http://raidenii.net/files/datasheets/misc/qr_code.pdf) 2, http://coolshell.cn/articles/10590.html 3, Galois Field 伽羅華域 (參考度娘) 4, Reed Solomon 錯誤修正編碼 (參考度娘) 5, Bitmap 編碼規範 (http://zh.wikipedia.org/wiki/Bitmap) 6, Base 64 編碼 (參考度娘)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.