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!
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745641586a4637725.html
评论列表(0条)