Code:
<!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" xml:lang="en" lang="en">
<head>
<title></title>
<style type="text/css">
/*<![CDATA[*/
#tst {
position:absolute;left:100px;top:20px;height:200px;width:100px;background-Color:red;
}
#tst1 {
position:absolute;left:300px;top:50px;height:200px;width:100px;background-Color:blue;
}
/*]]>*/
</style>
<script type="text/javascript">
/*<![CDATA[*/
function Scroll(id,ms){
this.obj=document.getElementById(id);
this.rstr=zxcWWHS()[3];
this.lst=zxcWWHS()[3];
this.tsrt=this.obj.offsetTop;
this.ms=ms||500;
this.scroll();
}
Scroll.prototype.scroll=function(){
var oop=this;
if (this.lst!=zxcWWHS()[3]){
this.obj.style.top=zxcWWHS()[3]+this.tsrt+'px';
this.lst=zxcWWHS()[3];
}
setTimeout(function(){ oop.scroll(); },this.ms);
}
function zxcWWHS(){
if (window.innerHeight) return [window.innerWidth-10,window.innerHeight-10,window.pageXOffset,window.pageYOffset];
else if (document.documentElement.clientHeight) return [document.documentElement.clientWidth-10,document.documentElement.clientHeight-10,document.documentElement.scrollLeft,document.documentElement.scrollTop];
return [document.body.clientWidth,document.body.clientHeight,document.body.scrollLeft,document.body.scrollTop];
}
/*]]>*/
</script>
</head>
<body onload="S1=new Scroll('tst',1000);S1=new Scroll('tst1',500);">
<div id="tst" ></div>
<div id="tst1" ></div>
<div style="height:2000px;" ></div>
</body>
</html>
or
Code:
<!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" xml:lang="en" lang="en">
<head>
<title></title>
<style type="text/css">
/*<![CDATA[*/
.tstp {
position:absolute;left:100px;top:120px;height:600px;width:120px;background-Color:red;
}
#tst {
position:absolute;left:10px;top:10px;height:60px;width:100px;background-Color:blue;
}
/*]]>*/
</style>
<script type="text/javascript">
/*<![CDATA[*/
function Scroll(id,ms){
this.obj=document.getElementById(id);
this.lst=zxcWWHS()[3];
this.tsrt=this.obj.offsetTop;
this.ms=ms||500;
this.scroll();
}
Scroll.prototype.scroll=function(){
var oop=this;
if (this.lst!=zxcWWHS()[3]){
this.obj.style.top=Math.max(Math.min(zxcWWHS()[3]+this.tsrt-zxcPos(this.obj.parentNode)[1],this.obj.parentNode.offsetHeight-this.obj.offsetHeight-this.tsrt),this.tsrt)+'px';
this.lst=zxcWWHS()[3];
}
setTimeout(function(){ oop.scroll(); },this.ms);
}
function zxcWWHS(){
if (window.innerHeight) return [window.innerWidth-10,window.innerHeight-10,window.pageXOffset,window.pageYOffset];
else if (document.documentElement.clientHeight) return [document.documentElement.clientWidth-10,document.documentElement.clientHeight-10,document.documentElement.scrollLeft,document.documentElement.scrollTop];
return [document.body.clientWidth,document.body.clientHeight,document.body.scrollLeft,document.body.scrollTop];
}
function zxcPos(obj){
var rtn=[obj.offsetLeft,obj.offsetTop];
while(obj.offsetParent!=null){
var objp=obj.offsetParent;
rtn[0]+=objp.offsetLeft;
rtn[1]+=objp.offsetTop;
obj=objp;
}
return rtn;
}
/*]]>*/
</script>
</head>
<body onload="S1=new Scroll('tst',1000);">
<div class="tstp" >
<div id="tst" ></div>
</div>
<div style="height:2000px;" ></div>
</body>
</html>
it would take 2K of extra code to add progressive scroll
Bookmarks