利用jquery的qrcode.js插件生成二维码的两种方式的使用
生活随笔
收集整理的這篇文章主要介紹了
利用jquery的qrcode.js插件生成二维码的两种方式的使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
利用jquery的qrcode.js插件生成二維碼的額兩種方式,canvas(即畫布)方式和table方式(原文地址http://www.helloweba.com/view-blog-226.html):
默認打開時是canvas生成。
當點擊時是table生成。
query_qrcode.html
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>演示:使用jquery.qrcode生成二維碼</title> <link rel="stylesheet" type="text/css" href="../css/main.css" /> <style type="text/css"> .demo{width:400px; margin:40px auto 0 auto; min-height:250px;} .demo p{line-height:30px} #code{margin-top:10px} </style> <script type="text/javascript" src="jquery-1.11.3.min.js"></script> <script type="text/javascript" src="jquery.qrcode.min.js"></script> <script type="text/javascript"> $(function(){var str = "http://www.helloweba.com";$('#code').qrcode(str);//canvas$("#sub_btn").click(function(){$("#code").empty();var str = toUtf8($("#mytxt").val());$("#code").qrcode({//tablerender: "table",width: 200,height:200,text: str});}); }) function toUtf8(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> </head><body> <div id="header"><div id="logo"><h1><a href="http://www.helloweba.com" title="返回helloweba首頁">helloweba</a></h1></div> </div><div id="main"><h2 class="top_title"><a href="http://www.helloweba.com/view-blog-226.html">使用jquery.qrcode生成二維碼</a></h2><div class="demo"><p>請輸入內容然后提交生成二維碼:</p><p><input type="text" class="input" id="mytxt" value=""> <input type="button" id="sub_btn" value="提交"></p><div id="code"></div></div></div><div id="footer"><p>Powered by helloweba.com 允許轉載、修改和使用本站的DEMO,但請注明出處:<a href="http://www.helloweba.com">www.helloweba.com</a></p> </div> </body> </html>?
轉載于:https://my.oschina.net/lenglingx/blog/871685
總結
以上是生活随笔為你收集整理的利用jquery的qrcode.js插件生成二维码的两种方式的使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 九宫重排_康拓展开_bfs
- 下一篇: java 内存模型 ——学习笔记