<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>js 动态生成二维码图片</title> <script type="text/javascript" src="QRCode.js" ></script> </head> <body> <div id="qrcode" style="width:200px; height:200px;position: fixed;bottom: 40%; right: 20%;"></div> <script type="text/javascript"> var qrcode = new QRCode(document.getElementById("qrcode"), { width : 200, height : 200 }); //输入你要生成的链接 var QRCodeUrl='http://onestopweb.iteye.com/'; qrcode.makeCode(QRCodeUrl); </script> </body> </html>
效果图:
PS:兼容IE6,火狐,谷歌,欧朋,苹果。