87,924
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<input type="button" value="pop" onclick="floatDiv.show('test')"/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<div id="test" style="width:300px;height:200px;display:none;position:absolute;background:#c0c0c0;">sdfasdfasdfasdf<input onclick="floatDiv.hide()" type="button" value="hide"/></div>
</BODY>
</HTML>
<SCRIPT LANGUAGE="JavaScript">
var floatDiv = function(){
var d = document,dd = d.documentElement,db = d.body,fd,sd,sdh, timer,timer2,time,step,mr = Math.round,isStrict = d.compatMode == "CSS1Compat";
return {
show:function(id){
time = 10;
if(!fd){
fd = d.body.appendChild(d.createElement('div'));
sd = d.getElementById(id);
fd.appendChild(sd);
sd.style.cssText += ';display:block;position:absolute;left:0;';
sdh = sd.offsetHeight;
fd.style.cssText = "overflow:hidden;position:absolute;bottom:0;right:0;width:"+sd.offsetWidth+"px;height:"+sdh+"px;";
}
fd.style.display = 'block';
sd.style.bottom = "-"+sdh+'px';
step = sdh/55;
timer = setInterval(function(){
if(time<0){
clearInterval(timer)
}else{
sd.style.bottom = parseInt(sd.style.bottom) + mr(time*step)+'px'
time -=1;
}
},10)
function scroll(){
var st = isStrict?dd.scrollTop:db.scrollTop,c,dbh = isStrict?dd.clientHeight:db.clientHeight,t = 500;
c = st - fd.offsetTop + (dbh-sdh);
c!=0&&(fd.style.top = fd.offsetTop + Math.ceil(c/10) + 'px',t=10);
timer2 = setTimeout(scroll,t)
};
scroll();
},
hide:function(){
time = 10;
clearTimeout(timer2);
timer = setInterval(function(){
if(time<0){
clearInterval(timer);
fd.style.display = 'none';
}else{
sd.style.bottom = parseInt(sd.style.bottom) - mr(time*step)+'px'
time -=1;
}
},10)
}
}
}()
</SCRIPT>