js 生成二维码

分手后的思念是犯贱 2022-04-08 09:08 507阅读 0赞

代码

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
  3. <head>
  4. <title>Javascript 二维码生成库:QRCode</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  6. <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
  7. <script type="text/javascript" src="http://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
  8. <script type="text/javascript" src="http://static.runoob.com/assets/qrcode/qrcode.min.js"></script>
  9. </head>
  10. <body>
  11. <input id="text" type="text" value="http://www.runoob.com" style="width:80%" /><br />
  12. <div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>
  13. <script type="text/javascript"> var qrcode = new QRCode(document.getElementById("qrcode"), { width : 100, height : 100 }); function makeCode () { var elText = document.getElementById("text"); if (!elText.value) { alert("Input a text"); elText.focus(); return; } qrcode.makeCode(elText.value); } makeCode(); $("#text"). on("blur", function () { makeCode(); }). on("keydown", function (e) { if (e.keyCode == 13) { makeCode(); } }); </script>
  14. </body>
  15. </html>

页面

在这里插入图片描述

发表评论

表情:
评论列表 (有 0 条评论,507人围观)

还没有评论,来说两句吧...

相关阅读