这个jQuery插件利用Google Chart API+jQuery来为移动设备生成QR二维码。默认将生成页面URL的QR码。当然你可以自己指定内容编码和设置QR码的大小。
Query二维码插件-改自MyQRCode
适用utf-8编码,支持中文字符.
调用方式:
- /**
- * @author Paul Chan / KF Software House
- * http://www.kfsoft.info
- *
- * Version 0.5
- * Copyright (c) 2010 KF Software House
- *
- * Licensed under the MIT license:
- * http://www.opensource.org/licenses/mit-license.php
- *
- */
- (function($) {
- var _options = null;
- jQuery.fn.MyQRCode = function(options) {
- _options = $.extend({}, $.fn.MyQRCode.defaults, options);
- return this.each(function()
- {
- var codebase = "https://chart.googleapis.com/chart?chs={size}&cht=qr&chl={content}&choe={encoding}";
- var mycode = codebase.replace(/{size}/g, _options.size);
- mycode = mycode.replace(/{content}/g, encodeURI(_options.content));
- mycode = mycode.replace(/{encoding}/g, _options.encoding);
- $(this).html("二维码加载中……");
- $(this).html("<img src='"+mycode+"'>");
- });
- }
- //default values
- jQuery.fn.MyQRCode.defaults = {
- encoding:"UTF-8",
- content: window.location,
- size:"150x150"
- };
- })(jQuery);
适用utf-8编码,支持中文字符.
调用方式: