index.html 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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>Cross-Browser QRCode generator for Javascript</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="jquery.min.js"></script>
  8. <script type="text/javascript" src="qrcode.js"></script>
  9. </head>
  10. <body>
  11. <input id="text" type="text" value="http://jindo.dev.naver.com/collie" style="width:80%" /><br />
  12. <div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>
  13. <script type="text/javascript">
  14. var qrcode = new QRCode(document.getElementById("qrcode"), {
  15. width : 100,
  16. height : 100
  17. });
  18. function makeCode () {
  19. var elText = document.getElementById("text");
  20. if (!elText.value) {
  21. alert("Input a text");
  22. elText.focus();
  23. return;
  24. }
  25. qrcode.makeCode(elText.value);
  26. }
  27. makeCode();
  28. $("#text").
  29. on("blur", function () {
  30. makeCode();
  31. }).
  32. on("keydown", function (e) {
  33. if (e.keyCode == 13) {
  34. makeCode();
  35. }
  36. });
  37. </script>
  38. </body>