JS生成名片,链接等二维码

& lt; div id=皅rcodeid祝辞& lt;/div>//生成的二维码放在此div中

& lt;脚本type=" text/javascript " src=" https://www.yisu.com/zixun/js/jquery.qrcode.min.js "祝辞& lt;/script>//引入qrcode.js(到)

& lt; script>

函数utf16to8 (str){,//解决中文乱码

,,,var,我,兰,c;,

,,,=" ";,

,,,len=str.length;,

,,,(我=0;我& lt;兰;我+ +){,

,,,c=str.charCodeAt(我);,

,,,如果((c祝辞=0 x0001),,(c & lt;=0 x007f)) {,

,,,,,+=str.charAt(我);,

,,,}else if (c比;0 x07ff) {,

,,,,,+=String.fromCharCode (0 xe0 | (c祝辞祝辞12),0 x0f));,

,,,,,+=String.fromCharCode (0 x80 | (c祝辞祝辞,6),0 x3f));,

,,,,,+=String.fromCharCode (0 x80 | (c祝辞祝辞,0),0 x3f));,

,,,其他}{

,,,,,+=String.fromCharCode (0 xc0 | (c祝辞祝辞,6),0 x1f));,

,,,,,+=String.fromCharCode (0 x80 | (c祝辞祝辞,0),0 x3f));,

,,,}

,,,}

,,,返回;,

},

& lt;/script>

& lt; script>//此处生成名片二维码(如要生成普通链接二维码则“文本”参数值直接替换成普通链接即可)

var the_text="开始:名片\ r \ nFN:姓名\ r \ nTEL;细胞,声音:15000000000 \ r \ nTITLE:职称\ r \ nORG公司(组织)\ r \ nEMAIL;互联网:123 @qq.com \ r \ nADR;工作,邮政:地球中国山东…\ r \ nURL: http://leerd.cn \ r \ nEND:名片”;

the_text=utf16to8 (the_text);

//警报(the_text);

jQuery (“# qrcodeid”)。qrcode ({

宽度:140,

高度:140,

呈现:“画布”//设置渲染方式表帆布

型数,:1,,,//计算模式,

correctLevel,,:0,//纠错等级,

的背景,,,:“# ffffff ",//背景颜色,

前景,,,:“# 000000 ",//前景颜色,

文本:the_text

});,

& lt;/script>


JS生成名片,链接等二维码