<script type="text/javascript">
// 保证悬浮的函数
function goScroll(o){
var space = document.getElementById(o).offsetTop; //获得层距离顶部的距离
document.getElementById(o).style.top = space+'px'; // 设置top属性
var goto = 0; // 定义需要移动距离的变量
window.setInterval(function(){
//document.documentElement.scrollTop获得滚动条纵坐标位置,document.body.scrollTop在ie5.5之后不支持
var height = document.documentElement.scrollTop + document.body.scrollTop + space;
var top = parseInt(document.getElementById(o).style.top);
if(height != top){ // 如果两者不一致,则需要移动
// 需要移动的距离是height-top
goto = height - parseInt((height-top)*1.1);
// 把层定位
document.getElementById(o).style.top = goto +'px';
}
}, 50);
}
function init(){ // 网页加载完就调用定位的函数
goScroll('con1');
}
// 保证悬浮的函数
function goScroll(o){
var space = document.getElementById(o).offsetTop; //获得层距离顶部的距离
document.getElementById(o).style.top = space+'px'; // 设置top属性
var goto = 0; // 定义需要移动距离的变量
window.setInterval(function(){
//document.documentElement.scrollTop获得滚动条纵坐标位置,document.body.scrollTop在ie5.5之后不支持
var height = document.documentElement.scrollTop + document.body.scrollTop + space;
var top = parseInt(document.getElementById(o).style.top);
if(height != top){ // 如果两者不一致,则需要移动
// 需要移动的距离是height-top
goto = height - parseInt((height-top)*1.1);
// 把层定位
document.getElementById(o).style.top = goto +'px';
}
}, 50);
}
function init(){ // 网页加载完就调用定位的函数
goScroll('con1');
}