层代码 可以拖动 可以关闭

来源:互联网 发布:秦文字编淘宝 编辑:程序博客网 时间:2024/04/28 10:06

<style type="text/css">
#netmoer {background-color:#000000;height:700px;width:1000px;position:absolute;left:0px;top:0px;}
#netmoera{border: 1px solid #666666;margin-top:1px;background-color: #FFFFFF;position: absolute;
height: 600px;width: 800px;float: left;}
.netmoeratitle{padding:0px 10px 0px 10px;border-bottom:1px solid #EEEEEE;        line-height: 30px;height: 30px;color: #000000;font-weight: bold;font-size: 16px;cursor: move;}
.netmoerainfo{height: 100%;width: 100%;margin-top: 0px;padding: 10px;}
.netshubiao{cursor:pointer;text-decoration: underline;}
</style>
</head>
<body>
<div id="bodyL">
<a class="netshubiao" onclick = "show('netmoer');return false;">
[网站公告]</a>
<a href="#" class="od" onclick = "closeed('netmoer');return false;">
</a>
</div>

<!--服务开始 -->
<div id="netmoer" style="display:none;filter:alpha(opacity=90); -moz-opacity:0.90;opacity:0.90;">
<div id="netmoera" class="netmorebox" style="left:10%;top:10%;">
<div class="netmoeratitle"><span style="float:left">点击可拖动</span><span style="float:right; margin-top:5px;"><input onclick = "closeed('netmoer');return false;" type="button" value="关闭" /></span>
</div>
<div class="netmoerainfo">
<iframe marginwidth="0" marginheight="0" height="100%" width="100%" scrolling="no" align="center" border="0" frameborder="0" src="http://www.sjg8.com/shop/">
</iframe>
</div>
</div>
</div>
<!--服务结务-->
<script type="text/javascript">
var prox;
var proy;
var proxc;
var proyc;
function show(id){/*--打开--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
o.style.display = "block";
o.style.width = "100%";
o.style.height = "100%";
prox = setInterval(function(){openx(o,1000)},10);
}
function openx(o,x){/*--打开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,700)},10);
}
}
function openy(o,y){/*--打开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){/*--关闭--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
if(o.style.display == "block")
{
proyc = setInterval(function(){closey(o)},10);
}
}
function closey(o){/*--打开y--*/
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)},10);
}
}
function closex(o){/*--打开x--*/
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";
}
}


/*===========鼠标拖动========*/
var ie=document.all;
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var y,x;
var oDragObj;

function moveMouse(e) {
if (isdrag) {
oDragObj.style.top = (nn6 ? nTY + e.clientY - y : nTY + event.clientY - y)+"px";
oDragObj.style.left = (nn6 ? nTX + e.clientX - x : nTX + event.clientX - x)+"px";
return false;
}
}

function initDrag(e) {
var oDragHandle = nn6 ? e.target : event.srcElement;
var topElement = "HTML";
while (oDragHandle.tagName != topElement && oDragHandle.className != "netmorebox") {
oDragHandle = nn6 ? oDragHandle.parentNode : oDragHandle.parentElement;
}
if (oDragHandle.className=="netmorebox") {
isdrag = true;
oDragObj = oDragHandle;
nTY = parseInt(oDragObj.style.top+0);
y = nn6 ? e.clientY : event.clientY;
nTX = parseInt(oDragObj.style.left+0);
x = nn6 ? e.clientX : event.clientX;
document.onmousemove=moveMouse;
return false;
}
}
document.onmousedown=initDrag;
document.onmouseup=new Function("isdrag=false");
</script>

原创粉丝点击