JS generates business cards, links, and other QR codes

Source: Internet
Author: User
Tags vcard

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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.