藉助二維碼生成外掛 ,純瀏覽器生成二維碼的的 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,完美,可以在頁面中生成二維碼