您的位置:首页 > Web前端 > JQuery

jQuery生成二维码

2015-07-02 11:33 639 查看
jQuery.qrcode

实例下载

jQuery生成二维码实例下载

<html>

<head>

<scripttype="text/javascript"src="jquery-1.3.2.min.js"></script>

<scripttype="text/javascript"src="jquery.qrcode-0.12.0.min.js"></script>


<scripttype="text/javascript">


$(function(){

$("#bcTarget").barcode("123456789","codabar",{barWidth:2,barHeight:80});

//二维码

$("#two").qrcode({

"render":"div",

"size":100,

"color":"#3a3",

"text":"http://liubo.club"

});


});


</script>

</head>

<body>



二维码


<br>

<divid="two"></div>

</body>

</html>

[/code]





<html>

<head>

<scripttype="text/javascript"src="jquery-1.3.2.min.js"></script>

<scripttype="text/javascript"src="jquery-barcode-2.0.1.js"></script>

<scripttype="text/javascript"src="jquery.qrcode-0.12.0.min.js"></script>


<scripttype="text/javascript">

//中文问题
functiontoUtf8(str){

varout,i,len,c;

out="";

len=str.length;

for(i=0;i<len;i++){

c=str.charCodeAt(i);

if((c>=0x0001)&&(c<=0x007F)){

out+=str.charAt(i);

}elseif(c>0x07FF){

out+=String.fromCharCode(0xE0|((c>>12)&0x0F));

out+=String.fromCharCode(0x80|((c>>6)&0x3F));

out+=String.fromCharCode(0x80|((c>>0)&0x3F));

}else{

out+=String.fromCharCode(0xC0|((c>>6)&0x1F));

out+=String.fromCharCode(0x80|((c>>0)&0x3F));

}

}

returnout;

}



$(function(){

$("#bcTarget").barcode("123456789","codabar",{barWidth:2,barHeight:80});

//二维码

$("#two").qrcode({

"render":"div",

"size":100,

"color":"#3a3",

"text":"http://liubo.club"

});

//生成条形码

$("#genid").click(function(){

		varcode=$("#orgcode").val();

		$("#mycode").barcode(code,"codabar",{barWidth:2,barHeight:80});

});

//生成二维码

$("#twobtn").click(function(){

		varqrcode=$("#twotext").val();

		qrcode=toUtf8(qrcode);

		$("#twoimg").qrcode({

"render":"div",

"size":100,

"color":"#3a3",

"text":qrcode

});


});



});


</script>

</head>

<body>

首先自动生成条形码123456789

<divid="bcTarget"></div>

输入要生成条形码的数字

<inputtype="text"id="orgcode">

<divid="mycode"></div>

<inputtype="button"value="生成条形码"id="genid"/>

<br>

<p>

liubo.club二维码


<br>

<divid="two"></div>


<p>

输入内容生成二维码

<inputtype="text"id="twotext"/>


<br>

<inputtype="button"value="生成二维码"id="twobtn"/>

<divid="twoimg"></div>

</body>

</html>

[/code]





关于生成的选项


Usage

Thesyntaxisverysimple.Justuse
$(selector).qrcode(options);

toappendanewgeneratedHTMLelementrepresentingtheQRcodetotheselectedelements.Iftheselectedelementalreadyisa
canvas
element,
thentheQRcodeisdrawnontoit.


Options

Theavailableoptionsandtheirdefaultvaluesare:
{
//rendermethod:'canvas','image'or'div'render:'canvas',

//versionrangesomewherein1..40minVersion:1,
maxVersion:40,

//errorcorrectionlevel:'L','M','Q'or'H'ecLevel:'L',

//offsetinpixelifdrawnontoexistingcanvasleft:0,
top:0,

//sizeinpixelsize:200,

//codecolororimageelementfill:'#000',

//backgroundcolororimageelement,nullfortransparentbackgroundbackground:null,

//contenttext:'notext',

//cornerradiusrelativetomodulewidth:0.0..0.5radius:0,

//quietzoneinmodulesquiet:0,

//modes//0:normal//1:labelstrip//2:labelbox//3:imagestrip//4:imageboxmode:0,

mSize:0.1,
mPosX:0.5,
mPosY:0.5,

label:'nolabel',
fontname:'sans',
fontcolor:'#000',

image:null}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: