-
Notifications
You must be signed in to change notification settings - Fork 0
/
web-url.html
88 lines (75 loc) · 2.89 KB
/
web-url.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="qrcode">
<meta name="author" content="ThrivingZhang,JingshanMao">
<title>二维码生成器</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/base.css">
</head>
<body>
<div class="page">
<div class="page-inner">
<div class="container">
<!-- 页面头部导航 -->
<header role="banner" class="masthead clearfix">
<nav role="navigation" class="inner">
<h3 class="masthead-brand"><a href="http://glyphicons.com/"><span class="glyphicon glyphicon-qrcode"></span></a> 二维码生成器</h3>
<ul class="nav masthead-nav">
<li><a href="index.html">文本</a></li>
<li class="active"><a href="web-url.html">网址</a></li>
<li><a href="vcard.html">名片</a></li>
<li><a href="wifi.html">WIFI</a></li>
</ul>
</nav>
</header>
<!-- 输入框 -->
<div class="content">
<div class="input-group">
<span class="input-group-addon">http://</span>
<input type="text" id="qrcode-content" class="form-control" placeholder="在这里输入网址">
<span class="input-group-btn"><button id="create-btn" class="btn btn-default">生 成</button></span>
</div>
<!-- 二维码的容器 -->
<div id="qrcode">
</div>
</div>
<!-- 页面页脚 -->
<footer class="mastfoot">
<div class="inner">
<p>制作人:张在兴 毛景山</p>
</div>
</footer>
</div>
</div>
</div>
<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="js/jquery.qrcode.min.js"></script>
<script type="text/javascript" src="js/to-utf8.js"></script>
<script>
jQuery(function(){
jQuery('#qrcode').qrcode(toUtf8("欢迎使用二维码生成器"));
canvasToImage();
jQuery("#create-btn").click(function(){
jQuery("#qrcode").empty(); /*清空 #qrcode*/
var str = "http://" + toUtf8(jQuery("#qrcode-content").val());
jQuery("#qrcode").qrcode(str);
canvasToImage(); /*将canvas转换成图片然后插入*/
});
});
/*
*canvasToImage:函数将canvas中的内容转换成png图像,然后在浏览器中就可以右击(手机中长按)->保存
*/
function canvasToImage() {
var mycanvas = document.getElementsByTagName("canvas");
var image = mycanvas[0].toDataURL("image/png");
var ement = "<img src='"+image+"'>";
jQuery("#qrcode").empty();
jQuery("#qrcode").append(ement);
}
</script>
</body>
</html>