-
Notifications
You must be signed in to change notification settings - Fork 12
Home
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);
}