js 二维码操作加上图标

//在这上面有可以生成两个二维码,具体可以自己看
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>紫光云计算</title>
		<script src="src/jquery-2.1.1.js" type="text/javascript">
</script>
		<script src="src/qrcode.js" type="text/javascript">
</script>
		<script src="src/jquery.qrcode.js" type="text/javascript">
</script>
		<style type="text/css">
/**二维码**/
html {
	background-attachment: fixed;
}

/*解决IE6下滚动抖动的问题*/ /*解决IE6下不兼容 position:fixed 的问题*/
#code_img {
	width: 208px;
	height: 208px;
	background: #ccc;
	position: fixed;
	right: 565px;
	bottom: 200px;
}

#div_div {
	width: 208px;
	height: 208px;
	background: #ccc;
	position: fixed;
	left: 200px;
	bottom: 200px;
}

#qrcode,#qrcodef {
	margin: 4px;
}

#qrcodef {
	margin: 4px;
}

#codeico {
	position: fixed;
	margin: 75px;
	width: 48px;
	height: 48px;
	background: url(img/delete.png) no-repeat;
}

#codeicof {
	position: fixed;
	margin: 75px;
	width: 48px;
	height: 48px;
	background: url(img/cross.png) no-repeat;
}
</style>
		<script type="text/javascript">
$(document).ready(function(e) {
	$("#codeico").hide();
	$("#codeicof").hide();

});
$(function() {
	$("#bt").bind("click", function() {
		text = $("#text").val();
		$("#qrcodef").empty();
		$("#qrcodef").append("<div id='codeicof'></div>");
		$("#qrcode").empty();
		$("#qrcode").append("<div id='codeico'></div>");
		jQuery("#qrcodef").qrcode( {
			render : "table",
			width : 200,
			height : 200,
			text : utf16to8(text)
		});
		//二维码显示
			jQuery('#qrcode').qrcode( {
				render : "table", //这里通过表格显示二维码 兼容低版本ie
				width : 200,
				height : 200,
				text : "youurl"
			});
			$("#codeico").show();
			$("#codeicof").show();
		});
})
function utf16to8(str) { //转码 
	var out, i, len, c;
	out = "";
	len = str.length;
	for (i = 0; i < len; i++) {
		c = str.charCodeAt(i);
		if ((c >= 0x0001) && (c <= 0x007F)) {
			out += str.charAt(i);
		} else if (c > 0x07FF) {
			out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
			out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
			out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
		} else {
			out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
			out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
		}
	}
	return out;
}
</script>
	</head>
	<body>
		<input type="text" id="text" />
		<input type="button" value="生成二维码" id="bt" />
		<div id="div_div">
			<div id="qrcodef">
				<div id="codeicof"></div>
			</div>
		</div>
		<div id="code_img">
			<div id="qrcode">
				<div id="codeico"></div>
			</div>
		</div>

	</body>
</html>
<img border="3" hspace="12" vspace="12" src="https://img-blog.youkuaiyun.com/20141023162245754?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjI1MTQyMQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" width="240" height="120" alt="" />
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值