Based on JavaScript to generate business cards, links and other two-dimensional code _javascript skills

Source: Internet
Author: User
Tags vcard

Nonsense not much said, directly affixed to the code, the specific contents are as follows;

<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) {//Resolve 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 >>) & 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 to generate a business card two-dimensional code (if you want to generate a normal link two-dimensional code then the "text" parameter value directly replace the normal 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 render mode table Canvas Typenumber:-1,//Calculation mode Corre 
ctlevel:0,//error correction level background: "#ffffff",//Background color foreground: "#000000",//Foreground color text:the_text}); </script>

The above content is the entire content of this article, I hope you like.

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.