admin管理员组文章数量:1026373
i am trying to generate qr code using this plugin:
/
my code is:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<input id="text" type="text" value="" style="width:80%" /><br />
<div id="qrcode"></div>
<script type="text/javascript" src="javascripts/qrcode.min.js">
var qrcode = new QRCode("qrcode");
</script>
</body>
</html>
but all i get is an input field with its value in it and no QR Code is generated. No errors in console either what could be the problem?
i am trying to generate qr code using this plugin:
http://davidshimjs.github.io/qrcodejs/
my code is:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<input id="text" type="text" value="https://hogangnono." style="width:80%" /><br />
<div id="qrcode"></div>
<script type="text/javascript" src="javascripts/qrcode.min.js">
var qrcode = new QRCode("qrcode");
</script>
</body>
</html>
but all i get is an input field with its value in it and no QR Code is generated. No errors in console either what could be the problem?
Share Improve this question edited Jun 9, 2018 at 16:17 Vinayak Shrivastava asked May 21, 2018 at 9:00 Vinayak ShrivastavaVinayak Shrivastava 1071 gold badge2 silver badges14 bronze badges3 Answers
Reset to default 1add
<script type="text/javascript" src="./javascripts/jquery.min.js"></script>
<script type="text/javascript" src="./javascripts/qrcode.min.js"></script>
to html
The <script>
element can have a "src" attribute or contents, but not both.
When you wrote
<script type="text/javascript" src="javascripts/qrcode.min.js">
var qrcode = new QRCode("qrcode");
</script>
you were trying to both load the qrcode javascript and specify your own javascript, which is not allowed with the <script>
element.
Instead, load the qrcode javascript (along with the jquery reference as Vinayak mentioned) inside your HTML file's <head>
section:
<script type="text/javascript" src="./javascripts/jquery.min.js"></script>
<script type="text/javascript" src="javascripts/qrcode.min.js"></script>
and then specify your own javascript inside its own script
element below (like you have it, without the "src" tag):
<script>
var qrcode = new QRCode("qrcode");
</script>
That should work for you.
Instead of writing
var qrcode = new QRCode("qrcode");
Write :-
var qrcode = new QRCode(document.getElementById("qrcode"), "*the name of site*");
The first parameter of the QRCode function is the div where you want the QRCode to be printed. Since you are not mentioning where to print the code, you are only getting the input box. Hope this helps!
i am trying to generate qr code using this plugin:
/
my code is:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<input id="text" type="text" value="" style="width:80%" /><br />
<div id="qrcode"></div>
<script type="text/javascript" src="javascripts/qrcode.min.js">
var qrcode = new QRCode("qrcode");
</script>
</body>
</html>
but all i get is an input field with its value in it and no QR Code is generated. No errors in console either what could be the problem?
i am trying to generate qr code using this plugin:
http://davidshimjs.github.io/qrcodejs/
my code is:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<input id="text" type="text" value="https://hogangnono." style="width:80%" /><br />
<div id="qrcode"></div>
<script type="text/javascript" src="javascripts/qrcode.min.js">
var qrcode = new QRCode("qrcode");
</script>
</body>
</html>
but all i get is an input field with its value in it and no QR Code is generated. No errors in console either what could be the problem?
Share Improve this question edited Jun 9, 2018 at 16:17 Vinayak Shrivastava asked May 21, 2018 at 9:00 Vinayak ShrivastavaVinayak Shrivastava 1071 gold badge2 silver badges14 bronze badges3 Answers
Reset to default 1add
<script type="text/javascript" src="./javascripts/jquery.min.js"></script>
<script type="text/javascript" src="./javascripts/qrcode.min.js"></script>
to html
The <script>
element can have a "src" attribute or contents, but not both.
When you wrote
<script type="text/javascript" src="javascripts/qrcode.min.js">
var qrcode = new QRCode("qrcode");
</script>
you were trying to both load the qrcode javascript and specify your own javascript, which is not allowed with the <script>
element.
Instead, load the qrcode javascript (along with the jquery reference as Vinayak mentioned) inside your HTML file's <head>
section:
<script type="text/javascript" src="./javascripts/jquery.min.js"></script>
<script type="text/javascript" src="javascripts/qrcode.min.js"></script>
and then specify your own javascript inside its own script
element below (like you have it, without the "src" tag):
<script>
var qrcode = new QRCode("qrcode");
</script>
That should work for you.
Instead of writing
var qrcode = new QRCode("qrcode");
Write :-
var qrcode = new QRCode(document.getElementById("qrcode"), "*the name of site*");
The first parameter of the QRCode function is the div where you want the QRCode to be printed. Since you are not mentioning where to print the code, you are only getting the input box. Hope this helps!
本文标签: javascriptqr code generator in jsStack Overflow
版权声明:本文标题:javascript - qr code generator in js - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745641585a2160780.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论