I wrote a simple GPLv3 qr encoder in javascript that is local, uses HTML5 and is really fast as it is a port of an embedded C version I wrote for Atmel AVR processors.
There is a live version (which is saveable as a webapp on iOS devices) at http://zdez.org/qrenc3.html (save to home, opens in safari so you can copy the image or use airprint)
There is a simple JavaScript library which I found sometime back called QRCode.js.
QRCode.js is a cross-browser JavaScript library which allows you to generate QRCodes on the fly, on the client-side. It makes use of HTMl5 Canvas and Tables to display the QRCode. The library itself has no dependencies whatsoever.
To generate a QRCode, you just need to include the JavaScript library and then pass as parameters to the QRCode function, the text you want to encode as the QRCode, the width & height of the QRCode you want to display, as well as your specified foreground color and background color.
I've found a working javascript-jquery based qrcode generator that you might be interested. Its opensource and it's really working. Here is the link: https://github.com/jeromeetienne/jquery-qrcode
The good thing about this one is that its light weight and it does not call any remote service or website.
Maksym's solution is better than Google's library because it runs at local does not need to call Google API. also if you don't use jQuery, you can use this one at https://github.com/amanuel/JS-HTML5-QRCode-Generator
Another HTML5 solution is http://davidshimjs.github.io/qrcodejs/ with IE6~10, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile browser compatibility
$ npm search qrcode
npm http GET https://registry.npmjs.org/-/all/since?stale=update_after&startkey=1379059929305
npm http 200 https://registry.npmjs.org/-/all/since?stale=update_after&startkey=1379059929305
NAME DESCRIPTION A
jsqrcode a node port of Lazar Laszlo's `jsqrcode` qr code decoder =
jsqrcode-lite Simplified version of Lazar Laszlo's `jsqrcode` for node. =
node-zxing ZXing Wrapper =
qr A small library to generate QR codes with libqrencode. =
qr-element qrcode dom element =
qr.js qrcode encoding in javascript =
qrcode QRCode / 2d Barcode api with both server side and client side s
qrcode-emitter Emits QR codes found in an image stream. =
qrcode-npm QRCode Generator for JavaScript =
qrcode-terminal QRCodes, in the terminal =
qrcode.js QR Code Detection / Decoding / Generation =
qread QRcode detector & decoder =
qruri NodeJS port of Kang Seonghoon's qr.js =
rescode Generate Codes (EAN13, QRCODE ..) =
zbar node-zbar is a NodeJS binding to the ZBar QR Code library.
npm has a few. I have no idea which ones are good.
$ npm search qrcode
npm http GET https://registry.npmjs.org/-/all/since?stale=update_after&startkey=1379059929305
npm http 200 https://registry.npmjs.org/-/all/since?stale=update_after&startkey=1379059929305
NAME DESCRIPTION A
jsqrcode a node port of Lazar Laszlo's `jsqrcode` qr code decoder =
jsqrcode-lite Simplified version of Lazar Laszlo's `jsqrcode` for node. =
node-zxing ZXing Wrapper =
qr A small library to generate QR codes with libqrencode. =
qr-element qrcode dom element =
qr.js qrcode encoding in javascript =
qrcode QRCode / 2d Barcode api with both server side and client side s
qrcode-emitter Emits QR codes found in an image stream. =
qrcode-npm QRCode Generator for JavaScript =
qrcode-terminal QRCodes, in the terminal =
qrcode.js QR Code Detection / Decoding / Generation =
qread QRcode detector & decoder =
qruri NodeJS port of Kang Seonghoon's qr.js =
rescode Generate Codes (EAN13, QRCODE ..) =
zbar node-zbar is a NodeJS binding to the ZBar QR Code library.
Update 2:
With var qr = new QRCode(10, QRErrorCorrectLevel.L); I was able to fit 271 chars in the QRCode however might not be the most reliable setting.
above is the link of js file include it in your project and write the below code in ctp file in cake php or any where you want to use. i tested it in cake php...
<-- including the file....
<?php echo $this->Html->script('jquery.qrcode.min.js')?>
<div style='padding:100px''><img id="demo" style='width: 100px,height: 100px'></div>
<script type="text/javascript">jQuery("#demo").qrcode({text: "HEllo World!"});</script>
I know this is an old question, but I think it is not necessary a library to generate a QR Code from a text. You just need to use the QR code API.
The implementation is very simple, we have a form with a text field that captures the content data. Whenever we press the generate button we generate a new request URL to the API this URL has two main components data and size. The former requires the text content encoded and the latter will define the size of the image. Here is the code:
const baseURL = 'https://api.qrserver.com/v1/create-qr-code/?data='
const config = '&size=120x120'
const btnElement = document.getElementById('generate')
const dataElement = document.getElementById('data')
const qrCode = document.querySelector('.qr-code')
function htmlDecode(text) {
var div = document.createElement('div')
div.innerHTML = text
return ('textContent' in div) ? div.textContent : div.innerText
}
function htmlEncode(str) {
var div = document.createElement('div')
div[('textContent' in div) ? 'textContent' : 'innerText'] = str
return div.innerHTML
}
window.onload = () => {
btnElement.onclick = () => {
qrCode.src = baseURL + encodeURIComponent(htmlEncode(dataElement.value)) + config
}
}
发布评论
评论(17)
我用 javascript 编写了一个简单的 GPLv3 qr 编码器,它是本地的,使用 HTML5,并且速度非常快,因为它是我为 Atmel AVR 处理器编写的嵌入式 C 版本的端口。
http://code.google.com/p/jsqrencode/downloads/list
有一个实时版本(可在 iOS 设备上另存为 Web 应用程序):http://zdez.org/qrenc3.html(保存到主目录,在 Safari 中打开,这样您就可以复制图像或使用airprint)
这是可下载源代码。
I wrote a simple GPLv3 qr encoder in javascript that is local, uses HTML5 and is really fast as it is a port of an embedded C version I wrote for Atmel AVR processors.
http://code.google.com/p/jsqrencode/downloads/list
There is a live version (which is saveable as a webapp on iOS devices) athttp://zdez.org/qrenc3.html (save to home, opens in safari so you can copy the image or use airprint)
Here is the link to the downloadable source code.
您发布的脚本可以运行,sample.html 不会被解析为 HTML。
Script you posted is WORKING, sample.html is not parsed as HTML.
jquery-qrcode jQuery 插件还使用 HTML5 canvas 元素或 HTML 表(如果不支持 canvas)生成 QR 代码。
https://github.com/jeromeetienne/jquery-qrcode
工作 jsFiddle 演示:
http://jsfiddle.net/maxim75/YwN8p/4/
jquery-qrcode jQuery plugin also generates QR code using HTML5 canvas element or HTML table, if canvas is not supported.
https://github.com/jeromeetienne/jquery-qrcode
Working jsFiddle demo:
http://jsfiddle.net/maxim75/YwN8p/4/
我之前发现了一个简单的 JavaScript 库,名为 QRCode.js。
QRCode.js 是一个跨浏览器 JavaScript 库,允许您在客户端动态生成 QRCode。它利用 HTMl5 Canvas 和 Tables 来显示 QRCode。该库本身没有任何依赖关系。
要生成 QRCode,您只需包含 JavaScript 库,然后将要编码为 QRCode 的文本、宽度和宽度作为参数传递给 QRCode 函数。您要显示的二维码的高度,以及您指定的前景色和背景色。
There is a simple JavaScript library which I found sometime back called QRCode.js.
QRCode.js is a cross-browser JavaScript library which allows you to generate QRCodes on the fly, on the client-side. It makes use of HTMl5 Canvas and Tables to display the QRCode. The library itself has no dependencies whatsoever.
To generate a QRCode, you just need to include the JavaScript library and then pass as parameters to the QRCode function, the text you want to encode as the QRCode, the width & height of the QRCode you want to display, as well as your specified foreground color and background color.
我找到了一个基于 javascript-jquery 的 qrcode 生成器,您可能会感兴趣。它是开源的并且确实有效。这是链接: https://github.com/jeromeetienne/jquery-qrcode
这个的特点是重量轻,并且不调用任何远程服务或网站。
I've found a working javascript-jquery based qrcode generator that you might be interested. Its opensource and it's really working. Here is the link: https://github.com/jeromeetienne/jquery-qrcode
The good thing about this one is that its light weight and it does not call any remote service or website.
Google 有一个二维码生成器作为其图表工具的一部分,您可以在此处使用。
http://code.google.com/apis/chart/infographics/docs/qr_codes.html< /a>
Google has a QR code generator as part of their Chart Tools that you can use here.
http://code.google.com/apis/chart/infographics/docs/qr_codes.html
最初帖子中的二维码仅支持最多 271 字节(版本 10,大小 = 57x57,EC 级别 L)。
为了使其支持 QR 码的完整规格(版本 40、177x177、2953 字节),您必须在其 RS_BLOCK_TABLE 中添加更多值。
请参阅此处的其余矩阵(版本 11-40):
http://two.pairlist.net/pipermail/reportlab-users /2010-9月/009707.html
The QR code in the initial post only supports up to 271 bytes (version 10, Size = 57x57, EC level L).
To make it support the full specs of QR code (version 40, 177x177, 2953 bytes), you have to add more values into its RS_BLOCK_TABLE.
See the remaining matrices (version 11-40) here:
http://two.pairlist.net/pipermail/reportlab-users/2010-September/009707.html
Maksym的解决方案比Google的库更好,因为它在本地运行不需要调用Google API。另外,如果您不使用 jQuery,您可以在 https://github 上使用这个。 com/amanuel/JS-HTML5-QRCode-Generator
Maksym's solution is better than Google's library because it runs at local does not need to call Google API. also if you don't use jQuery, you can use this one at https://github.com/amanuel/JS-HTML5-QRCode-Generator
我使用的是 ShieldUI Lite 二维码,可以在这里找到:
https://github.com/shieldui/ shieldui-lite
包含所有版本的 QR 码、所有错误级别。
I am using the ShieldUI Lite QR Code, which can be found here:
https://github.com/shieldui/shieldui-lite
Contains all versions of the QR Code, all Error levels.
另一个 HTML5 解决方案是 http://davidshimjs.github.io/qrcodejs/ 与
IE6~ 10、Chrome、Firefox、Safari、Opera、Mobile Safari、Android、Windows Mobile 浏览器兼容性
Another HTML5 solution is http://davidshimjs.github.io/qrcodejs/ with
IE6~10, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile
browser compatibility作为 Canvas/PNG
还有新的 kjua 来自与“旧”jQuery.qrcode。
作为 Canvas/PNG/SVG
和 QR-Code-generator by @nayuki 还能够将 QR 码创建为 SVG。
As Canvas/PNG
There is also the new kjua from the same author as the "old" jQuery.qrcode.
As Canvas/PNG/SVG
And QR-Code-generator by @nayuki also has the ability to create QR codes as SVGs.
您可以使用 Telerik Kendo-UI 生成qrcode 和条形码。它很容易使用。
尝试使用以下示例代码:
QR 代码: https://demos.telerik.com/kendo -ui/qrcode/index
条形码:https://demos.telerik。 com/kendo-ui/barcode/index
You can use Telerik Kendo-UI to generate qrcode and barcode. It is easy to use.
Try using this example code:
QR Code: https://demos.telerik.com/kendo-ui/qrcode/index
Barcode: https://demos.telerik.com/kendo-ui/barcode/index
npm 有一些。我不知道哪些是好的。
npm has a few. I have no idea which ones are good.
我找不到 JavaScript 二维码生成器。但是您可以考虑使用 Google 的 API:http://code.google.com/apis/chart/docs/gallery/qr_codes.html
http://togosoft.com/web/qrcode/qrcode.js
更新:
我刚刚尝试了 http://d-project.googlecode。 com/svn/trunk/misc/qrcode/js/qrcode.js 对我来说似乎很好。我做的唯一一件事就是增加大小并使其正确关闭 TD,因为自动关闭不是正确的 html。 http://k3rmit.org/nopaste/759
我测试了 3 个不同的字符串,并使用 iPhone 上一个名为 QRReader 的应用程序进行解码。
更新2:
使用 var qr = new QRCode(10, QRErrorCorrectLevel.L); 我能够在 QRCode 中容纳 271 个字符,但这可能不是最可靠的设置。
I couldn't find a javascript qr code generator.But you couldConsider using Google's API:http://code.google.com/apis/chart/docs/gallery/qr_codes.html
http://togosoft.com/web/qrcode/qrcode.js
Update:
I just tried http://d-project.googlecode.com/svn/trunk/misc/qrcode/js/qrcode.js and seems fine to me. The only thing I did was increase the size and made it close the TDs properly, since self closing is not correct html. http://k3rmit.org/nopaste/759
I tested 3 different strings and used a App called QRReader on my iPhone to decode.
Update 2:
With
var qr = new QRCode(10, QRErrorCorrectLevel.L);
I was able to fit 271 chars in the QRCode however might not be the most reliable setting.如果您找不到本机 JavaScript 实现,您始终可以从服务器自行 AJAX 图像。
http://www.swetake.com/qr/qr_cgi_e.html
If you can't find a native JavaScript implementation, you can always AJAX the image yourself from your server.
http://www.swetake.com/qr/qr_cgi_e.html
上面的https://drive.google.com/open?id=0B3TWIbBcUUTwcE1vV24wQnRxNGs
是js 文件的链接将其包含在您的项目中,并将以下代码写入 cake php 中的 ctp 文件或您想要使用的任何位置。我在蛋糕PHP中测试了它...
https://drive.google.com/open?id=0B3TWIbBcUUTwcE1vV24wQnRxNGs
above is the link of js file include it in your project and write the below code in ctp file in cake php or any where you want to use. i tested it in cake php...
我知道这是一个老问题,但我认为不需要一个库来从文本生成 QR 码。您只需使用二维码API即可。
实现非常简单,我们有一个带有捕获内容数据的文本字段的表单。每当我们按下生成按钮时,我们都会向 API 生成一个新的请求 URL,该 URL 有两个主要组成部分:
data
和size
。前者需要编码的文本内容,后者将定义图像的大小。这是代码:I know this is an old question, but I think it is not necessary a library to generate a QR Code from a text. You just need to use the QR code API.
The implementation is very simple, we have a form with a text field that captures the content data. Whenever we press the generate button we generate a new request URL to the API this URL has two main components
data
andsize
. The former requires the text content encoded and the latter will define the size of the image. Here is the code: