借助二维码生成插件 ,纯浏览器生成二维码的的 jQuery 插件!
1. 加载 jQuery 和 jquery.qrcode.js:
[javascript]
<script type=』text/javascript』 src=』http://cdn.staticfile.org/jquery/2.1.1/jquery.min.js』></script>
<script type="text/javascript" src="http://cdn.staticfile.org/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
[/javascript]
2. 创建一个用于包含 QRcode 图片的 DOM 元素,比如 div:
[html]
<div id="qrcode"></div>
[/html]
3. 然后通过下面代码生成 QRcode:
[html]
jQuery(『#qrcode』).qrcode("页面 URL")
[/html]
;
4. 默认生成的二维码大小是 256×256,当然可以自定义大小:
[html]
jQuery(『#qrcode』).qrcode({width: 64,height: 64,text: "页面 URL"});
[/html]
ok,完美,可以在页面中生成二维码!