随浏览器滚动条移动的DIV层的代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>随滚动条移动的层 - 5217.cn</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html" charset="gb2312">
<META NAME="Author" CONTENT="flasher">
<META NAME="homepage" CONTENT="www.5217.cn">
</HEAD>
<style>
<!--
.div{
 position: absolute;
 border: 2px solid red;
 background-color: #EFEFEF;
 line-height:90px;
 font-size:12px;
 z-index:1000;
}
-->
</style>
<BODY>
<div id="javascript.Div1" class="div" style="width: 240px; height:90px" align="center">正中...</div>
<SCRIPT LANGUAGE="javascript">
function sc1(){
 document.getElementById("javascript.Div1").style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-document.getElementById("javascript.Div1").offsetHeight)/2)+"px";
 document.getElementById("javascript.Div1").style.left=(document.documentElement.scrollLeft+(document.documentElement.clientWidth-document.getElementById("javascript.Div1").offsetWidth)/2)+"px";
}
</SCRIPT>


<div id="javascript.Div2" class="div" style="width: 240px; height:90px" align="center">左上...</div>
<SCRIPT LANGUAGE="javascript">
function sc2(){
 document.getElementById("javascript.Div2").style.top=(document.documentElement.scrollTop)+"px";
 document.getElementById("javascript.Div2").style.left=(document.documentElement.scrollLeft)+"px";
}
</SCRIPT>

<div id="javascript.Div3" class="div" style="width: 240px; height:90px" align="center">左下...</div>
<SCRIPT LANGUAGE="javascript">
function sc3(){
 document.getElementById("javascript.Div3").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById("javascript.Div3").offsetHeight)+"px";
 document.getElementById("javascript.Div3").style.left=(document.documentElement.scrollLeft)+"px";
}
</SCRIPT>

<div id="javascript.Div4" class="div" style="width: 240px; height:90px" align="center">右上...</div>
<SCRIPT LANGUAGE="javascript">
function sc4(){
 document.getElementById("javascript.Div4").style.top=(document.documentElement.scrollTop)+"px";
 document.getElementById("javascript.Div4").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("javascript.Div4").offsetWidth)+"px";
}
</SCRIPT>

<div id="javascript.Div5" class="div" style="width: 240px; height:90px" align="center">右下...</div>
<SCRIPT LANGUAGE="javascript">
function sc5(){
 document.getElementById("javascript.Div5").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById("javascript.Div5").offsetHeight)+"px";
 document.getElementById("javascript.Div5").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("javascript.Div5").offsetWidth)+"px";
}
</SCRIPT>


<SCRIPT LANGUAGE="javascript">
<!--
function scall(){
 sc1();sc2();sc3();sc4();sc5();
}
window.οnscrοll=scall;
window.οnresize=scall;
window.οnlοad=scall;
//-->
</SCRIPT>
<div style="position: absolute; top: 0px; left: 0px; width: 10000px; height: 4000px;"></div>
</BODY>
</HTML>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值