病みつきエンジニアブログ

機械学習、Python、Scala、JavaScript、などなど

QRcode generation plugin without jQuery

https://github.com/yamitzky/render-qrcode

To use the plugin, first, you have to load javascript like the following;

<script type="text/javascript" src="render.qrcode.min.js"></script>

then, you have to make an element a QRcode appended to.

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

finally, call qrcode() function of the element's DOM.

document.getElementById('qrcode-element').qrcode("text or options");

the argument is options or a text you want to generate QRcode.

the default options is the following;

default_options = {
			render		: "canvas", /* "canvas" or "table" is also supported */
			width		: 256,
			height		: 256,
			typeNumber	: -1,
			correctLevel	: QRErrorCorrectLevel.H, /* L, M, Q, H is supported */
                        background      : "#ffffff",
                        foreground      : "#000000"
		}

when you use options, you must specify text key like this.

element.qrcode({
  text: "text you want to generate qrcode",
  render: "table"
});