关于页面的自动滚动(javascript)

说好不能打脸
Java领域优质创作者
博客专家认证
2004-03-15 06:49:13
我的自动滚动代码如下:
<script language=javascript>
scrollx = 0;
function com_click()
{
if(document.getElementById("yy").checked == true)
{
scrollx = scrollx + 1
window.scrollTo(0,scrollx);
//setTimeout(com_click(),20)
timesave = setInterval(com_click(),20,javascript)
}
else
{
scrollx = 0;
cleartimeout(timesave)
}
return true
}

</script>


<div id=div1
style="BACKGROUND-COLOR: salmon; HEIGHT: 2000px; TOP: 800px; WIDTH: 500px">

<input type=checkbox id = yy name = yy onclick="tt()">


</div>

问题是:
1、速度很快(不论我将settimeout重的延时设为多少)
2、每次滚动到1/3处时就停止了。

如果那位高手又更好的请帖出来,让我这只菜鸟参考参考吧,谢谢。
...全文
164 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
说好不能打脸 2004-03-21
  • 打赏
  • 举报
回复
谢谢各位帮助
说好不能打脸 2004-03-21
  • 打赏
  • 举报
回复
自己再顶一下,实在不行就结贴了.....
lubaixu 2004-03-16
  • 打赏
  • 举报
回复
这样写吧:
<script language="JavaScript">
if(document.all){
document.writeln('<marquee direction=up id=xiaoer onmouseover=xiaoer.stop() onmouseout=xiaoer.start() height=170 scrollamount=1 scrolldelay=60 width=150>')
document.writeln('第一行内容<br>')
document.writeln('第二行内容<br>')
document.writeln('<img src=images/dot.gif>显示图片<br>')
document.writeln('等等')
document.writeln('</marquee>')
}else{document.writeln('no')
}
</script>
redstorm11 2004-03-16
  • 打赏
  • 举报
回复
go on uping
yhd0411 2004-03-16
  • 打赏
  • 举报
回复
<SCRIPT language=JavaScript>
var currentpos,timer;
function initialize()
{
timer=setInterval("scrollwindow()",50);
}
function sc(){
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos != document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</script>
heheyiyi 2004-03-16
  • 打赏
  • 举报
回复
http://search.csdn.net/expert/topic/3/304/2002/3/22/593535.htm
minghui000 2004-03-16
  • 打赏
  • 举报
回复
up
说好不能打脸 2004-03-15
  • 打赏
  • 举报
回复
顶一下吧?各位高手,看了一定要跟贴啊!!
ygghost 2004-03-15
  • 打赏
  • 举报
回复
<script language="JavaScript">
<!--
var i=0;
var kj=1;
var is_max=1;
var currentpos,timer;
function sc(){clearInterval(timer);}
function initialize(){timer=setInterval("scrollwindow()",1);}
function scrollwindow(){currentpos=document.body.scrollTop;window.scroll(0,++currentpos);}
document.onmousedown=sc
document.ondblclick=initialize
// End -->
</script>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧