Jquery插件-jquery-qrcode生成二维码
2017-03-14 21:16
357 查看
现在jquery.min.js和jquery.qrcode.min.js文件
先将js文件引入
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.qrcode.min.js"></script>
将要显示二维码的地方添加一下代码:
<div id="qrcode"></div>在文档尾引入设置代码:
<script type="text/javascript">
jQuery('#qrcode').qrcode({
width: 100,
height: 100,
render: "canvas", //设置渲染方式 table canvas
text: utf16to8("javascript生成二维码"),
background: "#ffffff", //背景颜色
foreground: "red" //前景颜色 F
});
//转码
function utf16to8(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>
先将js文件引入
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.qrcode.min.js"></script>
将要显示二维码的地方添加一下代码:
<div id="qrcode"></div>在文档尾引入设置代码:
<script type="text/javascript">
jQuery('#qrcode').qrcode({
width: 100,
height: 100,
render: "canvas", //设置渲染方式 table canvas
text: utf16to8("javascript生成二维码"),
background: "#ffffff", //背景颜色
foreground: "red" //前景颜色 F
});
//转码
function utf16to8(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>
相关文章推荐
- 菜鸟先飞之二维码jquery-qrcode插件生成
- jquery插件qrcode在线生成二维码
- 使用jQuery插件qrcode生成二维码
- 使用jquery插件qrcode生成二维码
- 基于jquery二维码生成插件qrcode
- 使用jquery插件qrcode生成二维码
- 使用jQuery的插件qrcode生成二维码(静态+动态生成)及常见问题解决方法
- 使用jQuery插件qrcode生成的二维码在微信中不能够识别
- jquery生成qrcode二维码
- 使用jquery-qrcode生成二维码
- 使用jquery-qrcode生成二维码
- jquery-qrcode生成二维码
- jquery qrcode二维码生成插件
- jquery-qrcode生成二维码
- jquery-qrcode客户端二维码生成类库扩展--融入自定义Logo图片
- jquery.qrcode.js 插件生成二维码
- 使用jquery-qrcode生成二维码
- 使用jquery-qrcode生成二维码
- 使用jquery-qrcode生成二维码
- 后台获取JQuery-qrcode生成的二维码图片