无聊时用动态原型改写的一个不间断向上滚动
2009-01-11 00:35
369 查看
<!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>
<script>
<!--
var i=0;
function $(ID)
{
var obj=document.getElementById(ID);
return obj;
}
function moveup(id,heigth)
{
this.id=id;
$(this.id+2).innerHTML=$(this.id+1).innerHTML
if(typeof(moveup._initialized=="undefined"))
{
moveup.prototype.move=function()
{
if($(this.id+2).offsetHeight-$(this.id).scrollTop<=0)
{
$(this.id).scrollTop-=$(this.id+1).offsetHeight;
}
else{
$(this.id).scrollTop++;
}
}
moveup._initialized=true;
}
}
-->
</script>
<style>
.demo{
width:400px;
height:20px;
background:#FF0000;
OVERFLOW: hidden;
padding:0px;
margin:0px;
}
.demo1{
width:400px;
padding:0px;
margin:0px;
}
</style>
</head>
<body>
<div id="demo" class="demo">
<div id="demo1" class="demo1">
1<br />
2<br />
3<br />
4<br />
5<br />
</div>
<div id="demo2"></div>
</div>
<script>
var rollspeed=100;
var obj=new moveup("demo",25);
var t=setInterval("obj.move()",rollspeed);
$("demo").onmouseover=function() {clearInterval(t)}//鼠标移上时清除定时器达到滚动停止的目的
$("demo").onmouseout=function() {t=setInterval("obj.move()",rollspeed)}//鼠标移开时重设定时器
</script>
</body>
</html>
以上代码只要把
if($(this.id+2).offsetHeight-$(this.id).scrollTop<=0)
{
$(this.id).scrollTop-=$(this.id+1).offsetHeight;
}
else{
$(this.id).scrollTop++;
}
里的scrollTop改为scrollLeft
offsetHeight改为offsetWidth就可以改为向左或向右滚动了
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>不间断向上滚动代码(无聊时用动态原型改写的)</title>
<script>
<!--
var i=0;
function $(ID)
{
var obj=document.getElementById(ID);
return obj;
}
function moveup(id,heigth)
{
this.id=id;
$(this.id+2).innerHTML=$(this.id+1).innerHTML
if(typeof(moveup._initialized=="undefined"))
{
moveup.prototype.move=function()
{
if($(this.id+2).offsetHeight-$(this.id).scrollTop<=0)
{
$(this.id).scrollTop-=$(this.id+1).offsetHeight;
}
else{
$(this.id).scrollTop++;
}
}
moveup._initialized=true;
}
}
-->
</script>
<style>
.demo{
width:400px;
height:20px;
background:#FF0000;
OVERFLOW: hidden;
padding:0px;
margin:0px;
}
.demo1{
width:400px;
padding:0px;
margin:0px;
}
</style>
</head>
<body>
<div id="demo" class="demo">
<div id="demo1" class="demo1">
1<br />
2<br />
3<br />
4<br />
5<br />
</div>
<div id="demo2"></div>
</div>
<script>
var rollspeed=100;
var obj=new moveup("demo",25);
var t=setInterval("obj.move()",rollspeed);
$("demo").onmouseover=function() {clearInterval(t)}//鼠标移上时清除定时器达到滚动停止的目的
$("demo").onmouseout=function() {t=setInterval("obj.move()",rollspeed)}//鼠标移开时重设定时器
</script>
</body>
</html>
以上代码只要把
if($(this.id+2).offsetHeight-$(this.id).scrollTop<=0)
{
$(this.id).scrollTop-=$(this.id+1).offsetHeight;
}
else{
$(this.id).scrollTop++;
}
里的scrollTop改为scrollLeft
offsetHeight改为offsetWidth就可以改为向左或向右滚动了
相关文章推荐
- MFC小程序003------MFC使用WebBrowser组件,在对话框中创建滚动视图,动态创建一个静态文本控件并设置鼠标单击的消息响应
- js图片不间断滚动代码(向上,向下,向左,向右)
- 文字不间断向上滚动--javascript+div+ul+li
- JS不间断向上滚动效果代码
- js文字不间断滚动(向上)
- 简短几句jquery代码的实现一个图片向上滚动切换。
- 网页中实现文字或图片向上不间断滚动的javascript代码
- 不间断向上滚动的文字特效(滚动一行暂停一段时间再滚动)(
- JS向上下左右不间断无缝滚动图片代码(兼容IE火狐)
- 图片不间断向上滚动JS
- MFC小程序003------MFC使用WebBrowser组件,在对话框中创建滚动视图,动态创建一个静态文本控件并设置鼠标单击的消息响应
- 图片、文字不间断向上、下、左、右滚动代码
- JS不间断向上滚动效果代码
- 不间断向上向左滚动
- JS不间断向上滚动代码
- js不间断向上滚动
- JS图片不间断滚动代码(向上,向下,向左,向右)
- JS实现单行文字不间断向上滚动的方法
- JS不间断向上滚动
- 简短几句jquery代码的实现一个图片向上滚动切换