Cross-browser QRCode generator for javascript

Related tags

React qrcodejs
Overview

QRCode.js

QRCode.js is javascript library for making QRCode. QRCode.js supports Cross-browser with HTML5 Canvas and table tag in DOM. QRCode.js has no dependencies.

Basic Usages

<div id="qrcode"></div>
<script type="text/javascript">
new QRCode(document.getElementById("qrcode"), "http://jindo.dev.naver.com/collie");
</script>

or with some options

<div id="qrcode"></div>
<script type="text/javascript">
var qrcode = new QRCode(document.getElementById("qrcode"), {
	text: "http://jindo.dev.naver.com/collie",
	width: 128,
	height: 128,
	colorDark : "#000000",
	colorLight : "#ffffff",
	correctLevel : QRCode.CorrectLevel.H
});
</script>

and you can use some methods

qrcode.clear(); // clear the code.
qrcode.makeCode("http://naver.com"); // make another code.

Browser Compatibility

IE6~10, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, ETC.

License

MIT License

Contact

twitter @davidshimjs

Bitdeli Badge

Comments
  • Security question!!!

    Security question!!!

    Question on safety! Is qrcode generated by this library stored in the browser cache? I could not find the exact confirmation, yes or no (( Browsers write that the code from the memory cache rises ... but whether they keep it on the disk is not clear ((( This affects the safe use of secret data in the code!

    opened by qrLogin 4
  • Fix SVG render mirroring

    Fix SVG render mirroring

    This fix makes SVG code to be rendered correctly. Without this fix qrcode.js produces SVG image in "mirrored" way. Some of qr-code scanners can't handle such code. E.g.: Scanvi for iOS

    opened by TriAnMan 4
  • Add SVG support

    Add SVG support

    The SVG support is used if the documentElement's tag name is "svg". I also made a demo page, it was tested in Chrome and Firefox, but it works a bit better in Firefox.

    opened by ysangkok 4
  • I use script tag to import qrcode.js, it works well, but when I package qrcode.js , it has a error.

    I use script tag to import qrcode.js, it works well, but when I package qrcode.js , it has a error.

    In main.js, I use these code to import qrcode.js

    import "../lib/qrcode.min"

    Then I package it use webpack, and open the html in browser, in the console:

    Uncaught TypeError: Cannot read property '_android' of undefined

    why? Can you help me? Thanks!

    opened by treadpit 3
  • vCard QR-Code is not scannable

    vCard QR-Code is not scannable

    When I generate a QR-Code from a .vcf-file the code appears, but I can't scan it. I tried different Correction Levels, types and scanners. Here is a generated Example-Code: image

    opened by iAmOnGitHubNow 2
  • Need an example with SVG on Basic Usages

    Need an example with SVG on Basic Usages

    Hi,

    I need an example on your GitHub Page to use this library when I want to make an SVG image. I need this to make a QR code on SVG to enhance printing.

    Best wishes,

    Martin

    opened by martinrios95 2
  • Seems to produce overly-complex codes for large input data

    Seems to produce overly-complex codes for large input data

    I'm comparing the output of this script with the version produced by the qrencode unix tool and it seems for a sample I'm using, the js produces a QR code which is far larger than it needs to be (compared to the unix tool), which results in it being too detailed for my camera to recognise it.

    I'm using a 734-character input to try it out, and the below images are the outputs of this library vs the unix tool (which I'm calling with docker run --rm giftig/qrencode -o - "$DATA")

    Please ignore the content, it's a set of notes for myself. I considered writing some sample nonsense to post instead but I don't mind the internet knowing about my quest to do some electrical work on my house.

    davidshimjs-qrcode

    qrencode-qrcode

    Forgive my ignorance of the details of how QR encoding works; I can't really speculate on what you're doing differently, but the result is clearly a far less space-optimised result. The latter image is recognised easily my by phone, and the former I have no doubt is a valid encoding of the same data, but is far too detailed to be viable.

    opened by giftig 2
  • Fixed syntax error in bower.json

    Fixed syntax error in bower.json

    bower.json has syntax error and bower can't install qrcode.js.

    $ bower install qrcode.js=https://github.com/davidshimjs/qrcodejs.git
    bower qrcode.js#*           not-cached https://github.com/davidshimjs/qrcodejs.git#*
    bower qrcode.js#*              resolve https://github.com/davidshimjs/qrcodejs.git#*
    bower qrcode.js#*             checkout master
    bower qrcode.js#*           EMALFORMED Failed to read /var/folders/s2/j1hmfp3s2814bqll10pjny180000gn/T/hanai/bower/qrcode.js-6803-fUODrr/bower.json
    
    Additional error details:
    Unexpected token ]
    
    opened by pirosikick 2
  • Uncaught TypeError: Cannot read properties of undefined (reading 'length')

    Uncaught TypeError: Cannot read properties of undefined (reading 'length')

    Getting a Uncaught TypeError: Cannot read properties of undefined (reading 'length') error every-time a QR Code is created. Qr code does get created successfully, but what is this issue?

    opened by timbogdanov 1
  • url内容太多,生成的二维码扫不了

    url内容太多,生成的二维码扫不了

    width: 74, height: 74, text: "http://wxh5.beta.hqjy.com/article/709?siteId=1&informationTypeId=139&informationType=2&provinceId=0", // colorDark: "#000", timer: null, colorLight: "#fff", correctLevel: this.$QRCode.CorrectLevel.L image 是我生成的方式错了嘛?

    opened by horizon188 1
  • DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.

    DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.

    After creating a QR Code, which is displayed and working properly, I get following error in the browser console:

    DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.

    I am using the following code to generate the qr code:

        if (this.qrcode) {
          this.qrcode.clear();
        }
    
        this.qrcode = new QRCode(document.getElementById('qrcode'), {
          logo: logoLink,
          text: link,
          width: 256,
          height: 256,
          colorDark: '#000000',
          colorLight: '#ffffff',
          correctLevel: QRCode.CorrectLevel.H,
          logoWidth: undefined,
          logoHeight: undefined,
          logoBackgroundColor: '#ffffff',
          logoBackgroundTransparent: false,
        });
    

    Any ideas on fixing this issue?

    opened by DonkeyKongJr 1
  • Incorrect string length computation

    Incorrect string length computation

    var qrcode = new QRCode(document.getElementById("qrcode"), {
      text: "01234567890abcd",
      correctLevel : QRCode.CorrectLevel.L
    });
    console.log(qrcode._oQRCode.getModuleCount());
    

    Should log 21 but this logs 25. The reason is _getUTF8Length is comparing a length to a string and almost always ends up adding 3 (*):

    	function _getUTF8Length(sText) {
    		var replacedText = encodeURI(sText).toString().replace(/\%[0-9a-fA-F]{2}/g, 'a');
    		return replacedText.length;
    	}
    

    I'm not 100% sure, but I think the following fix is correct:

    507c507
    < 		return replacedText.length + (replacedText.length != sText ? 3 : 0);
    ---
    > 		return replacedText.length;
    

    Happy to send a PR if there's agreement on this fix. Otherwise, I'll let people more familiar with this computation decide what's the correct fix.

    * It doesn't add 3 if replacedText equals "", "1", "02", etc. which are degenerate cases.

    opened by alokmenghrajani 0
  •  When using the IE8 browser to generate a QR code, the size of the QR code is distorted

    When using the IE8 browser to generate a QR code, the size of the QR code is distorted

    When using the IE8 browser to generate the QR code, the form of the table tag is used. There is a problem here: to calculate the height of each cell, use the Math.floor() method. When there is a lot of content, because of the downward rounding, the actual generated QR code size will be much smaller than the actual displayed one. As a guess, the more content, the more severe the size distortion. It is recommended to use the style attribute when generating the table tag to fix the width and height instead of using the sum of the width and height calculated by the cell as the final width and height of the QR code. aHTML.push('</table style=“width:100%;height:100%">'); We can set the size of table`s parent node directly and Using margin to make size will cause some strange scenes

    opened by asonglife 0
  • Added CDN Link

    Added CDN Link

    In the readme file, there is no CDN script to use it in the code. I have provided the CDN script so that developers can directly copy and paste it from the readme.

    opened by Indratejreddy 1
  • Android version regular expression needs update

    Android version regular expression needs update

    https://github.com/davidshimjs/qrcodejs/blob/04f46c6a0708418cb7b96fc563eacae0fbf77674/qrcode.js#L165

    This will prevent android versions above 8.0.0 from generating data URI because google changed versioning format, they don't use semantic versioning in user agent anymore just integer: 9, 10, 11, 12

    Best Regards.

    opened by aiamk 0
  • correct support of unicode texts #266 #236

    correct support of unicode texts #266 #236

    One can easily test, that library draws wrong QR-codes for some special inputs like new QRCode(elem "\x80"); new QRCode(elem, "\u0800"); // samaritan letter alaf or any string, conatining chars with codes greater than 0xFFFF new QRCode(elem, "🔥");

    The reasons are

    • minor bounds check mistakes
    • string method charCodeAt never returns codes greater than 0xFFFF, so one of the branches of QR8bitByte is never used!

    One should notice, that js support for unicode strings is pretty poor: "🔥".length === 2, even though every human would say, this string has one 'character'.

    P.S. qrcode.min.js should be updated also, i suppose, but i'm not sure which settings should be used, except smth like "preserve ie 6 compatibility"

    opened by se-ti 1
Owner
Sangmin, Shim
Sangmin, Shim
Mobile app development framework and SDK using HTML5 and JavaScript. Create beautiful and performant cross-platform mobile apps. Based on Web Components, and provides bindings for Angular 1, 2, React and Vue.js.

Onsen UI - Cross-Platform Hybrid App and PWA Framework Onsen UI is an open source framework that makes it easy to create native-feeling Progressive We

null 8.7k Jan 8, 2023
Boilerplate to build Cross-Platform Apps with Expo and React Native

Expo and React Native Boilerplate Boilerplate to build Cross-Platform Apps with Expo and React Native What are you going to find in this boilerplate E

José Ferrer 26 Apr 29, 2022
shouganaiyo-loader is a cross-platform Frida-based Node.js command-line tool that forces Java processes to load a Java/JVMTI agent regardless of whether or not the JVM has disabled the agent attach API.

shouganaiyo-loader: Forced Entry for Java Agents shouganaiyo-loader is a cross-platform Frida-based Node.js command-line tool that forces Java process

NCC Group Plc 20 Sep 19, 2022
Concircle scanner mobile app is application That helps you scan your order and position and to know if there are exact or not. it's cross-platform app.

Concircle scanner mobile app ⭐ Star on GitHub — it motivates Me a lot! Concircle scanner mobile app is application That helps you scan your order and

Aymen Ouerghui 10 May 7, 2022
⚛️ 🚀 A progressive static site generator for React.

You are viewing the docs for v7 of React Static. You can browse all historical versions via Github branches! React Static A progressive static-site ge

React Static 10.2k Dec 27, 2022
simple static website generator

mkweb mkweb is a simple static website generator for NodeJS Features: Simple and fast Templates (currently hard coded to "template.html") Markdown wit

Rasmus 48 Nov 6, 2022
😂 Meme Generator using React & imgflip API

Welcome to Meme Generator ?? ?? Meme Generator using React & imgflip API ✨ Video Installation Run yarn or npm install. Create an account here. Rename

Milhane. 2 Dec 19, 2021
Truth or Dare Generator App made using React.

Truth or Dare Generator App made using React.

ashish 3 Feb 28, 2022
Wallpaper generator in React.

Reactry's chessboard Reactry's chessboard is wallpaper generator written in React. goals ablity to select a custom color a button to randomize all opt

null 3 Oct 2, 2022
A frontend Framework for building B2B applications running in the browser on top of REST/GraphQL APIs, using ES6, React and Material Design

react-admin A frontend Framework for building data-driven applications running in the browser on top of REST/GraphQL APIs, using ES6, React and Materi

marmelab 21.2k Dec 30, 2022
Next-gen, highly customizable content editor for the browser - based on React and Redux and written in TypeScript. WYSIWYG on steroids.

ReactPage ReactPage is a smart, extensible and modern editor ("WYSIWYG") for the web written in React. If you are fed up with the limitations of conte

null 9.1k Jan 6, 2023
Purple haze is a TypeScript, Markdown, JS generative bundler that works in headless browser

Purple haze Inspired by generative programming and weed :). So I was learning Elm language at home usually in the evening and now I am missing all thi

Aexol 6 Nov 13, 2022
A fast-searching and space-saving browser specially designed for programmers.

Programmer Browser A fast-searching and space-saving browser specially designed for programmers. ⭐ Support Us If you like our project, do not forget t

Özgür 571 Jan 1, 2023
WPPConnect/mobile is an open source project with the objective of automating whatsapp web using the android or ios mobile browser and being able to perform all the functions of our wa-js project

WPPConnect/mobile is an open source project with the objective of automating whatsapp web using the android or ios mobile browser and being able to perform all the functions of our wa-js project, so it is possible to create a customer service, media sending, intelligence recognition based on artificial phrases and many other things, use your imagination to change and modify this project or collaborate on improvements...

null 11 Dec 28, 2022
The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.

Module SonarCloud Status ag-grid-community ag-grid-enterprise AG Grid AG Grid is a fully-featured and highly customizable JavaScript data grid. It del

AG Grid 9.5k Dec 30, 2022
Pickle tree - Javascript tree component made with pure javascript

Pickle Tree Pickle tree is a tree component written as completely pure javascript. Just send json file to object and have fun :-D Pickle tree does't n

Kadir Barış Bozat 17 Nov 13, 2022
A declarative, efficient, and flexible JavaScript library for building user interfaces.

React · React is a JavaScript library for building user interfaces. Declarative: React makes it painless to create interactive UIs. Design simple view

Facebook 200.2k Jan 8, 2023
JavaScript Testing utilities for React

Enzyme Enzyme is a JavaScript Testing utility for React that makes it easier to test your React Components' output. You can also manipulate, traverse,

enzyme - JavaScript Testing utilities for React 20k Dec 28, 2022
JavaScript data grid with a spreadsheet look & feel. Works for React, Angular, and Vue. Supported by the Handsontable team ⚡

Handsontable is a JavaScript component that combines data grid features with spreadsheet-like UX. It provides data binding, data validation, filtering

Handsontable 17.4k Jan 1, 2023