jQuery.qrCode.js实现二维码生成
2014-09-23 11:24
761 查看
代码如下:
<!DOCTYPE html> <html> <head> <title>basic example</title> </head> <style type="text/css"> *{margin:0;padding:0;font-family:微软雅黑;} #qrcode{border:1px solid #AFAFAF;width:200px;height:200px} </style> <body> <script src="../jQuery/jquery-1.9.1.min.js" type="text/javascript"></script> <script type="text/javascript" src="../jQuery/jquery.qrcode.js"></script> <script type="text/javascript" src="../jQuery/qrcode.js"></script> <p>Render in canvas</p> <div id="qrcode"></div> <script> //中文乱码,将UTF-16转换为UTF-8,UTF-16长度为2位,UTF-8为3位 String.prototype.toUTF8=function(){ var result = ""; //转码后的结果 for(var i=0,maxLen=this.length;i<maxLen;i++) { var t = this.charCodeAt(i); if( (t >= 0x0001) && (t <= 0x007F)) { result += this.charAt(i); } else if (t > 0x07FF) { result += String.fromCharCode(0xE0 | ((t >> 12) & 0x0F)); result += String.fromCharCode(0x80 | ((t >> 6) & 0x3F)); result += String.fromCharCode(0x80 | ((t >> 0) & 0x3F)); } else { result += String.fromCharCode(0xC0 | ((t >> 6) & 0x1F)); result += String.fromCharCode(0x80 | ((t >> 0) & 0x3F)); } } return result; } jQuery('#qrcode').qrcode({ render : "canvas" , //渲染方式:还可以为table方式 width : 200, //生成二维码的宽度 height : 200, //生成二维码的高度 typeNumber : -1, //计算方式 correctLevel : QRErrorCorrectLevel.H,//纠错等级 background : "#FFFFFF", //背景色 foreground : "#3399CC", //前景色 text : "许增强".toUTF8() //会乱码 }); </script> </body> </html>
相关文章推荐
- 使用jquery.qrcode.min.js实现前台二维码生成(带Logo)
- jquery.qrcode.min.js生成二维码 通过前端实现二维码生成
- 微信开发,解决jquery.qrcode.min.js生成二维码长按不识别问题
- 前端生成二维码 jquery.qrcode.js
- 使用Jquery.QRCode.js在web客户端生成二维码包括中文
- jQuery.qrcode.js客户端生成二维码,支持中文并且可以生成LOGO
- 二维码篇【一】【JS】使用jquery.qrcode生成二维码
- 使用jquery.qrcode.min.js实现中文转化二维码
- 使用jquery.qrcode.js生成二维码
- jQuery.qrcode.js客户端生成二维码,支持中文并且可以生成LOGO
- jquery.qrcode.min.js生成二维码插件
- (转)js jquery.qrcode生成二维码 带logo 支持中文
- 二维码篇【一】【JS】使用jquery.qrcode生成二维码
- 如何使用 jQuery.qrcode.js 生成二维码
- Qrcode生成二维码(logo篇)之jquery.qrcode.min.js
- 使用jquery.qrcode.js生成二维码插件
- Qrcode生成二维码普通篇之jquery.qrcode.min.js
- jquery.qrcode.js 插件生成二维码
- jQuery.qrcode.js客户端生成二维码,支持中文并且可以生成LOGO
- jQuery.qrcode.js客户端生成二维码,支持中文并且可以生成LOGO