jQuery二维码插件-改自MyQRCode,支持中文字符

jQuery二维码插件-改自MyQRCode
/**
 * @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编码,支持中文字符.
调用方式:
   <div id="qrocdes" style="width:160px;height:160px;border:1px solid #f00;"></div> 
  <SCRIPT type="text/javascript">
$("#qrocdes").MyQRCode({
encoding:"UTF-8",
content:'化蝶自在飞,来自湖北,http://www.xiaojudeng.com'
});
  </SCRIPT>


名片联系人信息格式如:
MECARD:N:孙悟空;
ADR:花果山;
TEL:+8613800138000;
Email:[email protected];

详细文档可参考:http://code.google.com/intl/zh-CN/apis/chart/infographics/docs/qr_codes.html

你可能感兴趣的:(jquery)