Skip to content
Serguei Shimansky edited this page Mar 16, 2017 · 1 revision

Welcome to the qrjs wiki!

Well this shows SVG element in Edge, and it resizes, But in IE 11 the svg stays 150x150. So a fallback to generatePNG would be most adequate:

if (document.implementation.hasFeature("http://www.w3.org/2000/svg", "1.1")) {
	var dataUriSvgImage = document.createElement("img"),
	u = "https://github.com",
	s = QRCode.generateSVG(u, {
			ecclevel: "M",
			fillcolor: "#FFFFFF",
			textcolor: "#373737",
			margin: 4,
			modulesize: 8
		});
	var XMLS = new XMLSerializer();
	s = XMLS.serializeToString(s);
	s = "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(s)));
	dataUriSvgImage.src = s;
	document.body.appendChild(dataUriSvgImage);
} else {
	var dataUriPngImage = document.createElement("img"),
	u = "https://github.com",
	s = QRCode.generatePNG(u, {
			ecclevel: "M",
			format: "html",
			fillcolor: "#FFFFFF",
			textcolor: "#373737",
			margin: 4,
			modulesize: 8
		});
	dataUriPngImage.src = s;
	document.body.appendChild(dataUriPngImage);
}
Clone this wiki locally