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.