JS generates business cards, links, and other QR codes
<Div id = "qrcodeid"> </div> // The generated QR code is stored in this div. <script type = "text/javascript" src = "js/jquery. qrcode. min. js "> </script> // introduce qrcode. js (to https://github.com/jeromeetienne/jquery-qrcode download) <script> function utf16to8 (str) {// solve Chinese garbled var out, I, len, c; out = ""; len = str. length; for (I = 0; I <len; I ++) {c = str. charCodeAt (I); if (c> = 0x0001) & (c <= 0x007F) {out + = str. charAt (I);} else if (c> 0x07FF) {out ++ = String. fromCharCode (0xE0 | (c> 12) & 0x0F); out + = String. fromCharCode (0x80 | (c> 6) & 0x3F); out + = String. fromCharCode (0x80 | (c> 0) & 0x3F);} else {out + = String. fromCharCode (0xC0 | (c> 6) & 0x1F); out + = String. fromCharCode (0x80 | (c> 0) & 0x3F) ;}} return out ;} </script> <script> // generate a business card QR code here (if you want to generate a common link QR code, replace the "text" parameter value with a common link) var the_text = "BEGIN: VCARD \ r \ nFN: Name \ r \ nTEL; CELL, VOICE: 15000000000 \ r \ nTITLE: Title \ r \ nORG: Company (organization) \ r \ nEMAIL; INTERNET, HOME: 123@qq.com \ r \ nADR; WORK, POSTAL: Earth China Shandong... \ r \ nURL: http://leerd.cn \ r \ nEND: VCARD "; the_text = utf16to8 (the_text); // alert (the_text); jQuery ('# qrcodeid '). qrcode ({width: 140, height: 140, render: "canvas", // set the rendering method table canvas typeNumber:-1, // calculation mode correctLevel: 0, // Error Correction level background: "# ffffff", // background color foreground: "#000000", // foreground color text: the_text}); </script>