<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