스크립트언어/jQuery

jQuery 로 qrcode 생성하는 방법 https://github.com/gcusnieux/jquery-qrcode

러키심 2018. 3. 19. 15:53
반응형




jQuery 로 qrcode 생성하는 방법


간단하게 jQuery 로 qrcode 를 구현하는 방법인데요. 아래 github 을 통해 사용해 봤습니다. 알다시피 url 경로로 잘 이동이 되지만 한글은 지원이 안되더군요.



How to Use It

Let me walk you thru it. First include it in your webpage with the usual script tag

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

Then create a DOM element which gonna contains the generated qrcode image. Lets say a div

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

Then you add the qrcode in this container by (한글은 깨짐 또는 인식 안됨)

jquery('#qrcode').qrcode("this plugin is great");

This is it. see it live.

You can set the height and width of the generated qrcode:

jquery('#qrcode').qrcode({width: 64,height: 64,text: "size doesn't matter"});


<html>
<head>
<title>basic example</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>

<!--<script type="text/javascript" src="../jquery.qrcode.min.js"></script>
--><script type="text/javascript" src="../src/jquery.qrcode.js"></script>
<script type="text/javascript" src="../src/qrcode.js"></script>

<p>Render in table</p>
<div id="qrcode"></div>
<p>Render in canvas</p>
<div id="qrcodeCanvas"></div>

<script>

//jQuery('#qrcode').qrcode("this is contents");
var parm = "http://aspdotnet.tistory.com/category/" + encodeURI("닷넷관련/디자인패턴").replace("%2F", "/");

jQuery('#qrcodeCanvas').qrcode({
width: 280,
height: 280,
text: parm
    }); 
</script>

</body>
</html>




반응형