!DOCTYPE html
創(chuàng)新互聯(lián)基于分布式IDC數(shù)據(jù)中心構(gòu)建的平臺為眾多戶提供成都服務(wù)器托管 四川大帶寬租用 成都機(jī)柜租用 成都服務(wù)器租用。
html
head
title/title
meta charset="utf-8"/
script src="js/qrcode.js"/script
style
#qrcode{
/*text-align: center;*/
/*display: table-cell;*/
/*width: 96px;*/
/*height: 96px;*/
/*vertical-align:middle;*/
/*position: relative;*/
}
/style
/head
body
div id="qrcode"
/div
input type="text" id="getval"/ button id="send"點(diǎn)擊更換驗(yàn)證碼/button
script
window.onload =function(){
var qrcode = new QRCode(document.getElementById("qrcode"), {
width : 96,//設(shè)置寬高
height : 96
});
qrcode.makeCode("");
document.getElementById("send").onclick =function(){
qrcode.makeCode(document.getElementById("getval").value);
}
}
/script
/body
/html
網(wǎng)上找的應(yīng)該有用 以后多度娘
div?id?=?"qrcodeid"/div?//生成的二維碼放在此?div?中
script?type="text/javascript"?src="js/jquery.qrcode.min.js"/script//引入qrcode.js(到?下載?)
script
function?utf16to8(str)?{?//解決中文亂碼
var?out,?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);?
}?else?if?(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));?
}?
}?
return?out;?
}?
/script
script//此處生成名片二維碼(如要生成普通鏈接二維碼?則?“text”參數(shù)值?直接替換成普通鏈接即可)
var?the_text?=?"BEGIN:VCARD?\r\nFN:姓名?\r\nTEL;CELL,VOICE:15000000000?\r\nTITLE:職稱?\r\nORG:公司(組織)?\r\nEMAIL;INTERNET,HOME:123@qq.com?\r\nADR;WORK,POSTAL:地球中國山東...?\r\nURL:?\r\nEND:VCARD";
the_text?=?utf16to8(the_text);
//alert(the_text);
jQuery('#qrcodeid').qrcode({
width:140,
height:140,
render:"canvas",?//設(shè)置渲染方式?table?canvas
typeNumber?:?-1,??//計(jì)算模式?
correctLevel??:?0,//糾錯等級?
background???:?"#ffffff",//背景顏色?
foreground???:?"#000000",//前景顏色?
text:the_text
});?
/script
參考以下代碼:
//創(chuàng)建BarcodeSettings實(shí)例
BarcodeSettings?settings?=?new?BarcodeSettings();
//設(shè)置條碼類型為QR二維碼
settings.setType(BarCodeType.QR_Code);???????
//設(shè)置二維碼數(shù)據(jù)
settings.setData("Hello?123456789");
//設(shè)置二維碼顯示數(shù)據(jù)
settings.setData2D("Hello?123456789");?????
//設(shè)置數(shù)據(jù)類型
settings.setQRCodeDataMode(QRCodeDataMode.Alpha_Number);
//設(shè)置二維碼模型寬度
settings.setX(1.0f);
//設(shè)置二維碼糾錯級別
settings.setQRCodeECL(QRCodeECL.H);
//創(chuàng)建BarCodeGenerator實(shí)例
BarCodeGenerator?barCodeGenerator?=?new?BarCodeGenerator(settings);
//根據(jù)settings生成圖像數(shù)據(jù),保存至BufferedImage實(shí)例
BufferedImage?bufferedImage?=?barCodeGenerator.generateImage();
//保存為PNG圖片
ImageIO.write(bufferedImage,?"png",?new?File("QRCode.png"));
System.out.println("Complete!");
需要引用Spire.Barcode for java
原文:Java 生成二維碼
文章標(biāo)題:javascript生成二維碼,js自動生成二維碼
當(dāng)前路徑:http://vcdvsql.cn/article14/dsdepge.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、面包屑導(dǎo)航、網(wǎng)站導(dǎo)航、商城網(wǎng)站、自適應(yīng)網(wǎng)站、移動網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)