实例介绍
【实例简介】下载直接使用
用javascript 将当前页面网址url 生成二维码
【实例截图】
【核心代码】
<html>
<head>
<base href="<%=basePath%>">
<title>二维码</title>
<meta http-equiv="pragma"content="no-cache">
<meta http-equiv="cache-control"content="no-cache">
<meta http-equiv="expires"content="0">
<meta http-equiv="keywords"content="keyword1,keyword2,keyword3">
<meta http-equiv="description"content="二维码">
<!--
<link rel="stylesheet"type="text/css"href="styles.css">
-->
<script type="text/javascript"src="js/jquery.js"></script>
<script type="text/javascript"src="js/qrcode.js"></script>
<script type="text/javascript"src="js/jquery.qrcode.js"></script>
<style>
#fd
{
width:120px;
height:120px;
background:white;
border: 1px solid black;
margin-top:2px;
margin-left:2px;
float:left;
overflow-y:auto;
overflow-x:hidden;
position:absolute;
left:400px;
/* bottom:260px; */
top:90px;
cursor:move;
float:left;
}
</style>
</head>
<body>
<br>
<div id="fd" style="display:none;filter:alpha(opacity=100);opacity:1;color:#849BCA;" >
<div id="erweima" style="width: 120px; float: left;padding-left: 5px;padding-top:5px;"></div>
<div style="float: right; padding-top: 50px; padding-right: 10px;">
<span>分 享 到</span> </br>
<span>微 信 朋 友 圈</span>
</div>
</div>
<div style="padding-top:200px;padding-left:500px;">
<span>
<input type="button" id="btn" value="二维码" onclick = "show('fd');" />
</span>
</div>
<script type="text/javascript">
var prox;
var proy;
var proxc;
var proyc;
/*--打开--*/
function show(id)
{
btn.onclick = function(){closeed('fd');}
btn.value = "二维码";
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
o.style.display = "block";
o.style.width = "1px";
o.style.height = "1px";
prox = setInterval(function(){openx(o,270)},0);
/*--生成二维码 --*/
jQuery('#erweima').qrcode({
width:120,
height:120,
render : "canvas",
text : document.URL
});
/*--生成二维码 --*/
}
/*--打开x--*/
function openx(o,x)
{
var cx = parseInt(o.style.width);
if(cx < x)
{
o.style.width = (cx Math.ceil((x-cx)/5)) "px";
}
else
{
clearInterval(prox);
proy = setInterval(function(){openy(o,135)},0);
}
}
/*--打开y--*/
function openy(o,y)
{
var cy = parseInt(o.style.height);
if(cy < y)
{
o.style.height = (cy Math.ceil((y-cy)/5)) "px";
}
else
{
clearInterval(proy);
}
}
/*--关闭--*/
function closeed(id)
{
btn.onclick = function(){show('fd');}
btn.value = "二维码";
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
if(o.style.display == "block")
{
proyc = setInterval(function(){closey(o)},0);
}
}
/*--关闭y--*/
function closey(o)
{
var cy = parseInt(o.style.height);
if(cy > 0)
{
o.style.height = (cy - Math.ceil(cy/5)) "px";
}
else
{
clearInterval(proyc);
proxc = setInterval(function(){closex(o)},0);
}
}
/*--关闭x--*/
function closex(o)
{
var cx = parseInt(o.style.width);
if(cx > 0)
{
o.style.width = (cx - Math.ceil(cx/5)) "px";
}
else
{
clearInterval(proxc);
o.style.display = "none";
$("#erweima").empty();
}
}
/*-------------------------鼠标拖动---------------------*/
/* var od = document.getElementById("fd");
var dx,dy,mx,my,mouseD;
var odrag;
var isIE = document.all ? true : false;
document.onmousedown = function(e)
{
var e = e ? e : event;
if(e.button == (document.all ? 1 : 0))
{
mouseD = true;
}
}
document.onmouseup = function()
{
mouseD = false;
odrag = "";
if(isIE)
{
od.releaseCapture();
od.filters.alpha.opacity = 100;
}
else
{
window.releaseEvents(od.MOUSEMOVE);
od.style.opacity = 1;
}
}
od.onmousedown = function(e)
{
odrag = this;
var e = e ? e : event;
if(e.button == (document.all ? 1 : 0))
{
mx = e.clientX;
my = e.clientY;
od.style.left = od.offsetLeft "px";
od.style.top = od.offsetTop "px";
if(isIE)
{
od.setCapture();
od.filters.alpha.opacity = 50;
}
else
{
window.captureEvents(Event.mousemove);
od.style.opacity = 0.5;
}
}
}
document.onmousemove = function(e)
{
var e = e ? e : event;
if(mouseD==true && odrag)
{
var mrx = e.clientX - mx;
var mry = e.clientY - my;
od.style.left = parseInt(od.style.left) mrx "px";
od.style.top = parseInt(od.style.top) mry "px";
mx = e.clientX;
my = e.clientY;
}
} */
/*处理中文*/
function toUtf8(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>
</body>
</html>
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明


网友评论
我要评论