[jQuery]jQuery做的二维码插件效果不错
时间:2016-10-30 来源:未知 点击:
[jQuery]jQuery做的二维码插件效果不错
- /**
- * @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);
- mycodemycode = mycode.replace(/{content}/g, encodeURI(_options.content));
- mycodemycode = 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);
- <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>
[jQuery]jQuery做的二维码插件效果不错