JS Generate business cards, links and other two-dimensional code

Source: Internet
Author: User
Tags vcard

<div id = "Qrcodeid" ></div>//generated two-dimensional stacking in this div

<script type= "Text/javascript" src= "Js/jquery.qrcode.min.js" ></script>//introduced qrcode.js (to https:// Github.com/jeromeetienne/jquery-qrcode download )

<script>

function Utf16to8 (str) {//solve Chinese garbled characters

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 >> 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;

}

</script>

<script>//here generate business card QR code (if you want to generate a normal link QR code, "text" parameter value is directly replaced with a normal link can be)

var the_text = "Begin:vcard \r\nfn: Name \r\ntel; cell,voice:15000000000 \r\ntitle: Title \r\norg: Company (Organization) \r\nemail;internet,home:[email protected] \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 render mode table canvas

Typenumber:-1,//Calculation mode

correctlevel:0,//Error Correction level

Background: "#ffffff",//Background color

Foreground: "#000000",//Foreground color

Text:the_text

});

</script>


JS Generate business cards, links and other two-dimensional code

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.