Skip to content

Javascript QRCode generator without dependencies with SVG or PNG (data-URL) output. MIT License.

License

Notifications You must be signed in to change notification settings

locandy/qrcodejs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QRCode.js

QRCode.js is a pure client-side javascript library for rendering QRCodes as SVG, canvas/PNG, or html table. QRCode.js has no dependencies, not even for the demo anymore.

Basic Usage

<div id="qrcode"></div>

<script type="text/javascript">
new QRCode(document.getElementById("qrcode"), "http://example.com");
</script>

or with some options

<div id="qrcode"></div>

<script type="text/javascript">
var qrcode = new QRCode(document.getElementById("qrcode"), {
	text: "http://example.com",
	width:  128,
	height: 128,
	border:   4,   // 4 is the default, and is standards-compliant
	output: "svg", // or "table" or the default "canvas" to generate a PNG data-URL.
	colorDark:    "#000000",
	colorLight:   "#ffffff",
	correctLevel: QRCode.CorrectLevel.H,
	imgStyle:     "display:block; max-width:100%; margin-left:auto; margin-right:auto;"
	    // style for img tag produced by canvas/png renderer
});
</script>

and you can use some methods

    qrcode.setCode("http://example.com");
        // change the qr code using all current settings and output method
    qrcode.destruct();
        // removes all created elements, canvas png, svg, table, follow by new QRCode(originalDiv, ...)
    
    // DEPRECATED:
    qrcode.clear();
        // DEPRECATED: svg and table same as destruct, but canvas/png works differently by only emptying canvas
        // this is for backwards compatibility
    qrcode.makeCode("http://example.com");
        // DEPRECATED calls setCode(str)

Demonstration

https://github.com/locandy/qrcodejs/blob/improve-documentation/index.html

Browser Compatibility

Edge, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, etc. and possibly even IE6~10.

License

MIT License

Upstream

About

Javascript QRCode generator without dependencies with SVG or PNG (data-URL) output. MIT License.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 80.1%
  • HTML 19.9%