javascript生成二维码
首先要引入
http://www.luqidong.com/demo/qrcode/js/qrcode.js
这个脚本
调用方法:
var qrcode = new QRCode(document.getElementById("qrcode"),{
width:96,
height:100
})
qrcode.makeCode("http://www.baidu.com");
例子:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8"/>
<!-- jquery的js -->
<script type="text/javascript" src="./jq.js"></script>
<!-- qrcodejs -->
<script src="./qr.js"></script>
<style>
#qrcode{
text-align: center;
display: table-cell;
width: 96px;
height: 96px;
vertical-align:middle;
position: relative;
}
</style>
</head>
<body>
<div id="qrcode">
</div>
<input type="text" id="getval"/> <button id="send">点击更换验证码</button>
<script>
$(function(){
var qrcode = new QRCode(document.getElementById("qrcode"),{
width:96,
height:100
})
qrcode.makeCode("http://www.baidu.com");
$('#send').click(function(){
qrcode.makeCode($('#getval').val());
})
})
</script>
</body>
</html>