实现代码一、
<script type="text/javascript">
//<![CDATA[
var tips; var theTop = 200/这是默认高度,越大越往下/; var old = theTop;
function initFloatTips() {
tips = document.getElementById('floatTips');
moveTips();
};
function moveTips() {
var tt = 50;
if (window.innerHeight) {
pos = window.pageYOffset
}
else if (document.documentElement && document.documentElement.scrollTop) {
pos = document.documentElement.scrollTop
}
else if (document.body) {
pos = document.body.scrollTop;
}
pos = pos - tips.offsetTop + theTop;
pos = tips.offsetTop + pos / 10;
if (pos < theTop) pos = theTop;
if (pos != old) {
tips.style.top = pos + "px";
tt = 10;
}
old = pos;
setTimeout(moveTips,tt);
}
//!]]>
<style type="text/css">
.floatTips
{
position: absolute;
border: solid 1px #777;
padding: 3px;
top: 250px;
right: 5px;
width: 30px;
height: 300px;
background: #cccccc;
color: white;
}
.showDiv
{
position: absolute;
border: solid 1px #777;
padding: 3px;
top: 250px;
right: 5px;
width: 300px;
height: 300px;
background: #cccccc;
color: white;
}