Using jquery packets to generate a two-dimensional code picture of a string _jquery

Source: Internet
Author: User

will be a string (can be Chinese, in the generation of two-dimensional code image before the Chinese transcoding code to generate two-dimensional code picture, if you want to take a log of two-dimensional code, you can create a two-dimensional code in the middle part of their own add a small log,log picture not too large, otherwise it will not scan out the content.

Copy Code code as follows:

<title></title>
<script src= "Js/jquery-1.8.3.js" type= "Text/javascript" ></script>
<script src= "Js/qrcode.js" type= "Text/javascript" ></script>
<script src= "Js/jquery.qrcode.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" >
$ (function () {
$ ("#bt"). Bind ("click", Function () {
Text = $ ("#text"). Val ();
$ ("#div_div"). QRCode (Utf16to8 (text));

})
})
function Utf16to8 (str) {//transcoding
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>
<body>
<input type= "text" id= "text"/>
<input type= "button" value= "SHENGC" id= "BT"/>
<div id= "Div_div" style= "width:400px;height:400px;border:1px solid #000;" ></div>
</body>

Here quoted three JS package, one is jquery package, this casual version, the other two is to draw two-dimensional code with the JS package.

JS Package Download http://download.csdn.net/detail/anxin591025/6254607

PS: Here again to provide a site of the two-dimensional Code generation tool enhanced version (with logos and a variety of custom functions) for everyone to use:

Http://tools.jb51.net/transcoding/jb51qrcode

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.