有个问题!~!~~~ function move(){if(Initialization) { if(i!=40)//这个数值要根据高度来定 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不懂楼上的意思噢if(i!=40) 那不是把所有的div都移到浏览器下面去拉?34是算出来的 移动速度是5 下面div的高度是170 170/5=34 水平还不够,所以还没打算写成控件的样式 我这里测试设为40后,内容部分(content)正好下移到不见,只露出蓝色的头部(title)。那么你要的是什么效果? 那就奇怪了 我这边是34刚好看不见content问题在: 当content移到浏览器的下面的时候 往下拉滚动条 ,一直拉不到底部.请指教了!~ 我是IE6 ,有这个问题这个还是有问题,我用ie6看别人的网站上的这个框框,隐藏content后 可以拉到底部. 手边没有IE6,不能帮你测试.不过我在FF下看了,兼容问题还挺多的. function move(){if(Initialization) { if(i!=40)//这个数值要根据高度来定 FF 相对严格一些,必须加上单位改了一下,IE6 和 FF 下没问题,没试 IE7修改的地方已经用注释标明<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loosevent.dtd"><html><head><title>测试</title><style type="text/css"> <!-- #xx{ position:absolute; width:200px;;border:1px solid #999999;}#title{font-size:12px;height:30px;width:100%;background:#0099FF;} #content{font-size:12px;height:170px;width:100%;}--> </style> <script> var Initialization =true //判断div是否滚动下去了 true没下去 false下去了var Opacity =100 //设置透明度var i=0window.onresize = resizeDiv;window.onscroll = resizeDiv;function resizeDiv(){divHeight = parseInt(document.getElementById("xx").offsetHeight,10);divWidth = parseInt(document.getElementById("xx").offsetWidth,10);docWidth = document.documentElement.clientWidth;docHeight = document.documentElement.clientHeight;if(Initialization){document.getElementById("xx").style.top = docHeight + parseInt(document.documentElement.scrollTop,10) - divHeight + "px";// 增加 pxdocument.getElementById("xx").style.left = docWidth + parseInt(document.documentElement.scrollLeft,10) - divWidth + "px";}// 增加 pxelse{document.getElementById("xx").style.top = docHeight + parseInt(document.documentElement.scrollTop,10) - divHeight + 170 + "px";// 增加 px}}function move(){if(Initialization) { if(i!=34) { i++; document.getElementById("xx").style.top=parseInt(document.getElementById("xx").style.top.replace("px","")) + 5 + "px";// 增加 replace ,增加 px tt=setTimeout("move()",10) } else {window.clearTimeout(tt); Initialization=false;}}else{ if(i!=0) { i-- document.getElementById("xx").style.top=parseInt(document.getElementById("xx").style.top.replace("px","")) - 5 + "px";// 增加 replace ,增加 px tt=setTimeout("move()",10) } else {Initialization=true;window.clearTimeout(tt)}}}function disappear(){if(Opacity==0){window.clearTimeout(time);document.getElementById('xx').style.display="none";}else{Opacity=Opacity-10;document.getElementById('xx').style.filter = "Alpha(opacity="+Opacity+")";time=setTimeout("disappear()",50)}}</script> <body onload="resizeDiv()"> hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br><div id="xx"><div id="title"><span style="top:7px;left:10px; position:relative;">新闻列表</span><span style="top:7px;left:105px; position:relative; cursor:hand;" onClick="move()">--</span><span style="top:7px;left:110px; position:relative; cursor:hand;" onClick="disappear()">X</span></div><div id="content"></div> </div> </body> </html> 试过了,IE7也没问题.FF下两个cursor:hand 也要改一下:cursor:pointer 10楼的朋友 好象+"px"只是兼容ff但是问题并没有解决 问题出来的过程是这样的:隐藏了content部分后 (就是按了"--"这个后,title并没有隐藏,就是那个兰色的标题栏还在)拖动框框 那个框框(蓝色的标题拦)无法到达底部,一直无限延伸.恩 就是这样 晕,忘了改了一下,应该可以了(IE6 和 FF 正常)<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loosevent.dtd"><html><head><title>测试</title><style type="text/css"> <!-- #xx{ position:absolute; width:200px;;border:1px solid #999999;}#title{font-size:12px;height:30px;width:100%;background:#0099FF;} #content{font-size:12px;height:170px;width:100%;}--> </style> <script> var Initialization = true; //判断div是否滚动下去了 true没下去 false下去了var Opacity = 100; //设置透明度var i = 0;window.onresize = resizeDiv;window.onscroll = resizeDiv;function resizeDiv(){divHeight = parseInt(document.getElementById("xx").offsetHeight,10);divWidth = parseInt(document.getElementById("xx").offsetWidth,10);docWidth = document.documentElement.clientWidth;docHeight = document.documentElement.clientHeight;if(Initialization){document.getElementById("xx").style.top = docHeight + parseInt(document.documentElement.scrollTop,10) - divHeight + "px";// 增加 pxdocument.getElementById("xx").style.left = docWidth + parseInt(document.documentElement.scrollLeft,10) - divWidth + "px";// 增加 px}else{document.getElementById("xx").style.top = docHeight + parseInt(document.documentElement.scrollTop,10) - divHeight + "px";// 增加 px,第二次修改去掉了 170}}function move(){if(Initialization){document.getElementById("content").style.display = "none";// 第二次修改if(i!=34) { i++; document.getElementById("xx").style.top=parseInt(document.getElementById("xx").style.top.replace("px","")) + 5 + "px";// 增加 replace ,增加 px tt=setTimeout("move()",10) } else {window.clearTimeout(tt); Initialization=false;}}else{document.getElementById("content").style.display = "block";// 第二次修改 if(i!=0) { i-- document.getElementById("xx").style.top=parseInt(document.getElementById("xx").style.top.replace("px","")) - 5 + "px";// 增加 replace ,增加 px tt=setTimeout("move()",10) } else {Initialization=true;window.clearTimeout(tt)}}}function disappear(){if(Opacity==0){window.clearTimeout(time);document.getElementById('xx').style.display="none";}else{Opacity=Opacity-10;document.getElementById('xx').style.filter = "Alpha(opacity="+Opacity+")";time=setTimeout("disappear()",50)}}</script> <body onload="resizeDiv()"> hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br><div id="xx"><div id="title"><span style="top:7px;left:10px; position:relative;">新闻列表</span><span style="top:7px;left:105px; position:relative; cursor:hand;" onClick="move()">--</span><span style="top:7px;left:110px; position:relative; cursor:hand;" onClick="disappear()">X</span></div><div id="content">aaaaaaaaaaa</div> </div> </body> </html> 嘿嘿明白你的意思了你是一开始就隐藏下面的content所以在document.getElementById("xx").style.top = docHeight + parseInt(document.documentElement.scrollTop,10) - divHeight + "px";中的divWidth已经减去了170, 估计浏览器是按照包括所有元素来显示大小的,所以我那样才会无限延. - -!这个我自己在修改成需要的样子非常感谢! 各位帮我看下代码 基于Jquery的一个倒计时的问题(新鲜的逻辑思维) $在js里是什么意思? 如何连续播放多个flash文件??? split能不能把字符串从右边开始取值再给数组?~~ 急!动态表格中某一行的颜色问题,请给代码,我是用html作的 在线等:怎样得到这个窗口的对象。 javascript的一个问题(帮忙看看几行代码为什么错误) 如何实现以下网址的一些功能,参与有分! 本人需要做一个自动向上滚动的页面,但需要表头固定该怎么做呢? Aptana 关键字的问题 [十万火急]DIV移动层右键问题
if(i!=40) 那不是把所有的div都移到浏览器下面去拉?
34是算出来的 移动速度是5 下面div的高度是170 170/5=34
水平还不够,所以还没打算写成控件的样式
那么你要的是什么效果?
问题在: 当content移到浏览器的下面的时候 往下拉滚动条 ,一直拉不到底部.
请指教了!~
这个还是有问题,我用ie6看别人的网站上的这个框框,隐藏content后 可以拉到底部.
if(Initialization)
{ if(i!=40)//这个数值要根据高度来定
改了一下,IE6 和 FF 下没问题,没试 IE7修改的地方已经用注释标明<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loosevent.dtd">
<html>
<head>
<title>测试</title>
<style type="text/css">
<!--
#xx{ position:absolute; width:200px;;border:1px solid #999999;}
#title{font-size:12px;height:30px;width:100%;background:#0099FF;}
#content{font-size:12px;height:170px;width:100%;}
-->
</style>
<script>
var Initialization =true //判断div是否滚动下去了 true没下去 false下去了
var Opacity =100 //设置透明度
var i=0
window.onresize = resizeDiv;
window.onscroll = resizeDiv;
function resizeDiv()
{
divHeight = parseInt(document.getElementById("xx").offsetHeight,10);
divWidth = parseInt(document.getElementById("xx").offsetWidth,10);
docWidth = document.documentElement.clientWidth;
docHeight = document.documentElement.clientHeight;
if(Initialization)
{document.getElementById("xx").style.top = docHeight + parseInt(document.documentElement.scrollTop,10) - divHeight + "px";// 增加 px
document.getElementById("xx").style.left = docWidth + parseInt(document.documentElement.scrollLeft,10) - divWidth + "px";}// 增加 px
else
{
document.getElementById("xx").style.top = docHeight + parseInt(document.documentElement.scrollTop,10) - divHeight + 170 + "px";// 增加 px
}
}function move(){
if(Initialization)
{ if(i!=34)
{
i++;
document.getElementById("xx").style.top=parseInt(document.getElementById("xx").style.top.replace("px","")) + 5 + "px";// 增加 replace ,增加 px
tt=setTimeout("move()",10)
}
else
{window.clearTimeout(tt); Initialization=false;}
}
else
{
if(i!=0)
{
i--
document.getElementById("xx").style.top=parseInt(document.getElementById("xx").style.top.replace("px","")) - 5 + "px";// 增加 replace ,增加 px
tt=setTimeout("move()",10)
}
else
{Initialization=true;window.clearTimeout(tt)}
}
}function disappear(){
if(Opacity==0)
{window.clearTimeout(time);
document.getElementById('xx').style.display="none";}
else
{
Opacity=Opacity-10;
document.getElementById('xx').style.filter = "Alpha(opacity="+Opacity+")";
time=setTimeout("disappear()",50)
}
}
</script> <body onload="resizeDiv()">
hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>
<div id="xx">
<div id="title">
<span style="top:7px;left:10px; position:relative;">新闻列表</span>
<span style="top:7px;left:105px; position:relative; cursor:hand;" onClick="move()">--</span>
<span style="top:7px;left:110px; position:relative; cursor:hand;" onClick="disappear()">X</span>
</div>
<div id="content"></div>
</div>
</body>
</html>
试过了,IE7也没问题.
FF下两个cursor:hand 也要改一下:cursor:pointer
但是问题并没有解决
问题出来的过程是这样的:
隐藏了content部分后 (就是按了"--"这个后,title并没有隐藏,就是那个兰色的标题栏还在)
拖动框框 那个框框(蓝色的标题拦)无法到达底部,一直无限延伸.
恩 就是这样
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loosevent.dtd">
<html>
<head>
<title>测试</title>
<style type="text/css">
<!--
#xx{ position:absolute; width:200px;;border:1px solid #999999;}
#title{font-size:12px;height:30px;width:100%;background:#0099FF;}
#content{font-size:12px;height:170px;width:100%;}
-->
</style>
<script>
var Initialization = true; //判断div是否滚动下去了 true没下去 false下去了
var Opacity = 100; //设置透明度
var i = 0;
window.onresize = resizeDiv;
window.onscroll = resizeDiv;
function resizeDiv(){
divHeight = parseInt(document.getElementById("xx").offsetHeight,10);
divWidth = parseInt(document.getElementById("xx").offsetWidth,10);
docWidth = document.documentElement.clientWidth;
docHeight = document.documentElement.clientHeight;
if(Initialization){
document.getElementById("xx").style.top = docHeight + parseInt(document.documentElement.scrollTop,10) - divHeight + "px";// 增加 px
document.getElementById("xx").style.left = docWidth + parseInt(document.documentElement.scrollLeft,10) - divWidth + "px";// 增加 px
}else
{
document.getElementById("xx").style.top = docHeight + parseInt(document.documentElement.scrollTop,10) - divHeight + "px";// 增加 px,第二次修改去掉了 170
}
}function move(){
if(Initialization)
{
document.getElementById("content").style.display = "none";// 第二次修改
if(i!=34)
{
i++;
document.getElementById("xx").style.top=parseInt(document.getElementById("xx").style.top.replace("px","")) + 5 + "px";// 增加 replace ,增加 px
tt=setTimeout("move()",10)
}
else
{window.clearTimeout(tt); Initialization=false;}
}
else
{
document.getElementById("content").style.display = "block";// 第二次修改
if(i!=0)
{
i--
document.getElementById("xx").style.top=parseInt(document.getElementById("xx").style.top.replace("px","")) - 5 + "px";// 增加 replace ,增加 px
tt=setTimeout("move()",10)
}
else
{Initialization=true;window.clearTimeout(tt)}
}
}function disappear(){
if(Opacity==0)
{window.clearTimeout(time);
document.getElementById('xx').style.display="none";}
else
{
Opacity=Opacity-10;
document.getElementById('xx').style.filter = "Alpha(opacity="+Opacity+")";
time=setTimeout("disappear()",50)
}
}
</script> <body onload="resizeDiv()">
hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>hehe<br>
<div id="xx">
<div id="title">
<span style="top:7px;left:10px; position:relative;">新闻列表</span>
<span style="top:7px;left:105px; position:relative; cursor:hand;" onClick="move()">--</span>
<span style="top:7px;left:110px; position:relative; cursor:hand;" onClick="disappear()">X</span>
</div>
<div id="content">aaaaaaaaaaa</div>
</div>
</body>
</html>
明白你的意思了
你是一开始就隐藏下面的content
所以在
document.getElementById("xx").style.top = docHeight + parseInt(document.documentElement.scrollTop,10) - divHeight + "px";
中的divWidth已经减去了170,
估计浏览器是按照包括所有元素来显示大小的,所以我那样才会无限延. - -!
这个我自己在修改成需要的样子
非常感谢!