文章出處
文章列表
1)query.barcode.js安裝
同其他jquery插件一樣,只需要將jquery框架和jquery.barcode.js導入頁面即可。
<script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript" src="jquery-barcode.js"></script>
2)jquery.barcode.js使用方法
2.1)定義一個DOM對象作為條形碼/二維碼的容器
<div id="bcTarget"></div>
2.2)使用javascript調用jquery.barcode.js繪制條形碼/二維碼
$("#bcTarget").barcode("1234567890128", "ean13");
jquery對象擴展方法barcode參數說明
barcode: function(datas, type, settings)
1.datas參數支持2種類型
- string:要繪制的條形碼字符串內容(依賴于條形碼的類型)。如果條形碼類型能容納這些字符,并且存在校驗不是強制性的,字符串的ISE將會自動計算(原文:If barcode type include it, the presence of the checksum is not mandatory, it ise automatically recalculated)
- object
2.type (string):條形碼類型
- codabar
- code11 (code 11)
- code39 (code 39)
- code93 (code 93)
- code128 (code 128)
- ean8 (ean 8)
- ean13 (ean 13)
- std25 (standard 2 of 5 - industrial 2 of 5)
- int25 (interleaved 2 of 5)
- msi
- datamatrix (ASCII + extended)
3.settings (object):條形碼樣式的配置
barWidth(條形碼款)、barHeight(容器高)、showHRI(是否顯示條形碼內容)、bgColor(背景色)、color(條形碼顏色)、fontSize(內容字體大小)、output(如何繪制條形碼:css,svg,bmp,canvas,注意svg,bmp,canvas不支持IE,最好不用。)
示例代碼
<input type="button" onclick='$("#bcTarget").barcode("1234567890128", "ean13",{barWidth:2, barHeight:30});' value="ean13"> <input type="button" onclick='$("#bcTarget2").barcode("1234567", "int25",{barWidth:2, barHeight:30});' value="int25"> <input type="button" onclick='$("#bcTarget3").barcode({code: "1234567", crc:false}, "int25",{barWidth:2, barHeight:30});' value="int25 without crc">
文章列表
全站熱搜