A vcard is a data specification that allows personal information to be exchanged, and the vcard data format identifier is the Vcard,vcard data format line: type [; parameter]: value, Specific Introduction Baidu has, we can through the vcard to save the address Book, the exchange of business cards
Basic format:
Begin:vcardn: surname, name;;; FN: First name title:xx Group front-end ADR; work:;; No. 19th, GT Road, Wu Huan District, Beijing;;; TEL; Cell,voice:159351111111tel; Work,voice:010-6666666url; Work:www.gt.comemail;internet,home:[email Protected]end:vcard
Includes information such as the name of the job address, landline phone, email, and other basic information
Here, two-dimensional Code business card sharing and sharing method through the mobile scan of the function to save contacts
The tool that generates the QR code uses the Qrcode.js principle and the fodder to convert the string into a two-dimensional code rendered out here is his introduction http://code.ciaoca.com/javascript/qrcode/
Simple Way New QRCode (document.getElementById (' QRCode '), Business card information vcard string;//Set parameter mode var qrcode = new QRCode (' QRCode ', { text : ' Your content ', width:256, height:256, colordark: ' #000000 ', foreground colorlight: ' #ffffff ', background color Correctlevel:qrcode.correctlevel.h});//Use Apiqrcode.clear (); Qrcode.makecode (' new content ');
First define a string format for a vcard that can be recognized by a mobile phone
var A, B = "Last Name", C = "First Name", d = "xx Group front end", e = "No. 19th GT Road, Beijing Five ring zone", g = "159351111111", h = "010-6666666",
i = "Www.gt.com", j = "[email protected]";
Stitching a vcard string
A = "Begin:vcard", A + = "\r\nn:" + B + ";" + C + ";;", A + = "\R\NFN:" + C + " " + B, D && (A + = "\r\ntitle:" + D), e && (A + = "\R\NADR; work:;; "+ E +";;;; "), G && (A + =" \r\ntel; Cell,voice: "+ g), H && (A + =" \r\ntel; Work,voice: "+ h), I && (a + =" \r\nurl; Work: "+ i", J && (A + = "\r\nemail;internet,home:" + j), A + = "\r\nend:vcard"
This is a little clearer:
A = "Begin:vcard", A + = "\r\nn:" + B + ";" + C + ";;", A + = "\R\NFN:" + C + " " + B, D && (A + = "\r\ntit LE: "+ D), e && (A + =" \R\NADR; work:;; "+ E +";;;; "), G && (A + =" \r\ntel; Cell,voice: "+ g), H && (A + =" \r\ntel; Work,voice: "+ h), I && (a + =" \r\nurl; Work: "+ i", J && (A + = "\r\nemail;internet,home:" + j), A + = "\r\nend:vcard"
Then use Jquery.qrcode.min.js
$ ("#qrcode"). HTML (""); $ ("#qrcode"). QRCode ({width:270, height:270, correctlevel:0,text:a});
Here is a point is garbled phenomenon this is because the Chinese code is not uniform, so we have to use a conversion method
/*utf16 to Utf8*/function utf16to8 (str) { 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 + = S Tring.fromcharcode (0xE0 | ((c >> b) & 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;}
On the Go QR code
$ ("#qrcode"). QRCode ({width:270, height:270, correctlevel:0,text:meg});
:
By scanning you will get
Through Xiaomi phone you will get
Such a personal business card can be shared to complete the sweep can be added to the other side of their phone address book
There's a lot of points out there. Include end sharing business card, canvas QR code display Android phone will not appear in the identification map QR code and so on continue to write
Use vcard and qrcode.js to generate QR code to import contacts