引入JS文件
<script type="text/javascript" src="./jquery.min.js"></script>
<script type="text/javascript" src="./jquery.qrcode.min.js"></script>
创建显示二维码区域
<div id="qrcode"></div>
生成二维码代码
简单调用:
$('#qrcode').qrcode(toUtf8(str));
带参数调用:
$('#qrcode').qrcode({text:toUtf8(str), width:500, height:500, correctlevel:0});
支付中文函数
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; }
上一篇:jquery-easyui datagrid 高度自适应布局
下一篇:jquery+layer.tips实现鼠标滑入滑出显示或关闭
讨论数量:0