我们在制作手机网页时.经常需要点击生成二维码,以供别人扫描,以下是代码
<div style="text-align:center;">
<div><div id="qrcode"></div></div>
<p style="margin-top:8px; color:#999;">扫一扫上面的二维码图案,查看我的资料</p>
</div>
可以先设置一个div 用来承装生成的二维码
导入jquery.qrcode.min.js(见资源链接)
然后:
$("#qrcode").qrcode({
render: "table", //table方式
width: 246, //宽度
height:246, //高度
text:"http://219.142.99.55:8000/WeChatHelper/group_tongxunlu_xq.html?userno="+userno//Paht+"/group_tongxunlu_xq.html?userno="+userno//
//text对应的是二维码所附带的内容.手机扫描后就将跳转至/219.142.99.55:8000/WeChatHelper/group_tongxunlu_xq.html页面
});
$("#qrcode table").css("width","100%");//可以设置二维码宽
var h =$("#qrcode table").width();
$("#qrcode table").css("height",h);//设置二维码高与宽相同
下载js地址:http://download.csdn.net/detail/yubin2009m/9450417