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[*/
.header {
left:0px;top:0px;width:100%;height:280px;
}
#float {
position:absolute;z-Index:1000;left:0px;top:100px;width:100%;height:100px;border:solid red 1px;
}
#float IMG{
position:absolute;z-Index:1000;left:0px;top:0px;width:100%;height:100%;
}
/*]]>*/
</style></head>
<body>
<div style="height:2000px;" ></div>
<div id="float">
<img src="http://www.vicsjavascripts.org.uk/StdImages/One.gif" />
</div>
<script type="text/javascript">
/*<![CDATA[*/
function Float(o){
var oop=this,obj=document.getElementById(o.ID);
this.obj=obj;
this.top=obj.offsetTop;
this.max=obj.offsetHeight;
this.min=o.MimimumSize||this.max;
setInterval(function(){ oop.fix(); },50);
}
Float.prototype={
fix:function(){
var wwhs=this.wwhs();
this.obj.style.top=(wwhs[3]>this.top?0:this.top)+'px';
this.obj.style.height=(wwhs[3]>this.top?this.min:this.max)+'px';
this.obj.style.width=wwhs[0]+'px';
this.obj.style.position=wwhs[3]>this.top?'fixed':'absolute';
},
wwhs:function(){
if (window.innerHeight) return [window.innerWidth-5,window.innerHeight-5,window.pageXOffset,window.pageYOffset];
else if (document.documentElement.clientHeight) return [document.documentElement.clientWidth-5,document.documentElement.clientHeight-5,document.documentElement.scrollLeft,document.documentElement.scrollTop];
return [document.body.clientWidth,document.body.clientHeight,document.body.scrollLeft,document.body.scrollTop];
}
}
new Float({
ID:'float',
MimimumSize:35
});
/*]]>*/
</script>
</body>
</html>
Bookmarks