index.svg 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?xml version="1.0" standalone="yes"?>
  2. <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="-50 0 200 100">
  3. <g id="qrcode"/>
  4. <foreignObject x="-50" y="0" width="100" height="100">
  5. <body xmlns="http://www.w3.org/1999/xhtml" style="padding:0; margin:0">
  6. <div style="padding:inherit; margin:inherit; height:100%">
  7. <textarea id="text" style="height:100%; width:100%; position:absolute; margin:inherit; padding:inherit">james</textarea>
  8. </div>
  9. <script type="application/ecmascript" src="qrcode.js"></script>
  10. <script type="application/ecmascript">
  11. var elem = document.getElementById("qrcode");
  12. var qrcode = new QRCode(elem, {
  13. width : 100,
  14. height : 100
  15. });
  16. function makeCode () {
  17. var elText = document.getElementById("text");
  18. if (elText.value === "") {
  19. //alert("Input a text");
  20. //elText.focus();
  21. return;
  22. }
  23. qrcode.makeCode(elText.value);
  24. }
  25. makeCode();
  26. document.getElementById("text").onkeyup = function (e) {
  27. makeCode();
  28. };
  29. </script>
  30. </body>
  31. </foreignObject>
  32. </svg>