蓝森林首页 | 返回主页 | 本站地图 | 站内搜索 | 联系信箱 |
 您目前的位置:首页 > 自由软件 > 技术交流 > 应用编程


    

蓝森林 http://www.lslnet.com 2006年8月25日 8:28

javascript控制的层纵向滚动时能否控制滚动到某个位置就自动停止?

一个用javascript控制的层,纵向滚动,可以控制距页面顶部的距离,我想实现的是当页面向下滚动并且层跟着滚动时,滚动到某个位置就不再滚动了。应该怎么呢?
<SCRIPT lanuage="javascript">
function layermove(){
        if (screen.width>900){
                layerright.style.top=document.body.scrollTop+32;
                setTimeout("layermove();",30);
        }else
        {
                layerright.style.display='none';
        }
}
layermove();
</SCRIPT>

示例网址:http://cgi.ebay.com.cn/ws/eBayISAPI.dll?ViewItem&ssPageName=STRK%3AMESE%3AIT&item=9526315844&rd=1

我想实现的效果就是能在上下两个表格之间滚动。有知道的吗,谢谢了
[html]
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
        margin-left: 0px;
        margin-top: 0px;
        margin-right: 0px;
        margin-bottom: 0px;
}
-->
</style></head>

<body><div align="left">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="100" bgcolor="#006633">&nbsp;</td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="80%" height="1000" valign="top">&nbsp;</td>
    <td width="20%" align="left" valign="top"><DIV id=layerright style="Z-INDEX: 1; RIGHT: 5px; LEFT: 785px; VISIBILITY: visible; WIDTH: 140px; POSITION: absolute; TOP: 32px; HEIGHT: 540px; background: #999999; layer-background-color: #999999; border: 1px none #000000;">
<SCRIPT lanuage="javascript">
function layermove(){
        if (screen.width>900){
                layerright.style.top=document.body.scrollTop+102;
                setTimeout("layermove();",30);
        }else
        {
                layerright.style.display='none';
        }
}
layermove();
</SCRIPT>
</DIV>
</td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="100" bgcolor="#006633">&nbsp;</td>
  </tr>
</table>
</div>
</body>
</html>
[/html]


[html]<body>
<table width=100% height=300 bgcolor=tan id=oTop><tr><td align=center>table top</td></tr></table>
<div id=oDiv style="position:absolute;background-color:skyblue">scrolling div</div>
<table width=100% height=400 ><tr><td align=center>table middle</td></tr></table>
<table width=100% height=300 bgcolor=tan id=oBottom><tr><td align=center>table bottom</td></tr></table>
</body>
<script>
var nTop=oTop.offsetTop+oTop.clientHeight;
var nBottom=oBottom.offsetTop-oDiv.clientHeight;
(function(){var x=nTop+document.body.scrollTop;oDiv.style.posTop=(x<nBottom?x:nBottom);setTimeout(arguments.callee,30)})();
</script>[/html]

非常感谢!




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 蓝森林网站 版权所有。 E-mail : webmaster@lslnet.com