HTML頁面JS事件生成本頁面URL二維碼,可以手機掃描

 很簡單,直接貼代碼:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>qrcode</title>
  </head>
	<body>
		<div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>

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

			<script type="text/javascript">
				//初始化存放二維碼的div
				var qrcode = new QRCode(document.getElementById("qrcode"), {
					width : 100,
					height : 100
				});
				//window.location.href獲取到URL
				qrcode.makeCode(window.location.href);

		</script>
	</body>
</html>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章