jquery realizes "sweep code reading" function _jquery

Source: Internet
Author: User

Today saw a user sent a topic, "PC-side URL on the mobile end of the open to knock a good trouble, what good way?" ”。

Indeed now is the mobile era, reading on mobile devices will become the mainstream, the site if there is no convenient way for users to read in mobile devices is really a bit outdated, so think about doing a "sweep code reading" function. In fact, it is very simple, that is, the Web site generated two-dimensional code on the line.

Whether it's generated in PHP or JavaScript, it makes it easier to use JavaScript from code churn. So let's use jquery here. There is a jquery.qrcode.js extension on the Internet that can be used. It's also easy to use, like this:

Then use the micro-letter, pay the treasure purse or sweep a sweep can be opened in the mobile phone browser, very convenient, thanks to Jquery.qrcode.js's author.

The code to generate the QR code is as follows:

Copy Code code as follows:

<div id= "QRCode" ></div>
<script src= "Http://www.xxx.net/librarys/application/views/veda/js/jquery-1.6.1.min.js" type= "Text/javascript ">
<script src= "Http://www.xxx.net/librarys/application/views/veda/js/jquery.qrcode.min.js" type= "text/ JavaScript ">
<script type= "Text/javascript" >
Jquery.noconflict ();
JQuery ("#qrcode"). QRCode ({
Render: "Canvas",//table Way
width:150,//width
height:150,//height
Text: ' http://www.xxx.net/'/any Content
});
</script>

Jquery.qrcode.js is actually through the use of jquery to achieve graphics rendering, drawing, support canvas (HTML5) and table two ways, the default use of Canvas method, the most efficient, of course, browser support HTML5. The direct call is as follows:

Copy Code code as follows:

JQuery (' #code '). QRCode ("http://www.xxx.net/");

If the browser does not support HTML5, or if you want to configure the size of the picture, you can do so in this way:

Copy Code code as follows:

JQuery ("#code"). QRCode ({
Render: "Canvas",//canvas or Table way
width:150,//width
height:150,//height
Text: ' http://www.xxx.net/'//content
});

Now blog every article on the right side has generated QR code, you can sweep, read on the phone.

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.