Skip to content

Commit 696776b

Browse files
committed
Merge pull request #23 from sembrestels/svg-html
Added support for SVG QR codes into HTML.
2 parents 1c78ccd + f57b643 commit 696776b

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

index-svg.html

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
3+
<head>
4+
<title>Cross-Browser QRCode generator for Javascript</title>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6+
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
7+
<script type="text/javascript" src="jquery.min.js"></script>
8+
<script type="text/javascript" src="qrcode.js"></script>
9+
</head>
10+
<body>
11+
<input id="text" type="text" value="http://jindo.dev.naver.com/collie" style="width:80%" />
12+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
13+
<g id="qrcode"/>
14+
</svg>
15+
<script type="text/javascript">
16+
var qrcode = new QRCode(document.getElementById("qrcode"), {
17+
width : 100,
18+
height : 100,
19+
useSVG: true
20+
});
21+
22+
function makeCode () {
23+
var elText = document.getElementById("text");
24+
25+
if (!elText.value) {
26+
alert("Input a text");
27+
elText.focus();
28+
return;
29+
}
30+
31+
qrcode.makeCode(elText.value);
32+
}
33+
34+
makeCode();
35+
36+
$("#text").
37+
on("blur", function () {
38+
makeCode();
39+
}).
40+
on("keydown", function (e) {
41+
if (e.keyCode == 13) {
42+
makeCode();
43+
}
44+
});
45+
</script>
46+
</body>
47+
</html>

qrcode.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,10 @@ var QRCode;
557557
if (typeof el == "string") {
558558
el = document.getElementById(el);
559559
}
560+
561+
if (this._htOption.useSVG) {
562+
Drawing = svgDrawer;
563+
}
560564

561565
this._android = _getAndroid();
562566
this._el = el;

0 commit comments

Comments
 (0)