解决方案 »

  1.   

    本帖最后由 showbo 于 2013-08-08 17:54:19 编辑
      

  2.   

    firefox12,ie7,8,chrome都没有问题,测试过的,你什么浏览器
      

  3.   

    哦哦,我知道了,你的这段代码如果加上
    <!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">
    就不起作用了,能不能让他符合这个标准啊?
      

  4.   

    忘记xhtml了,改成下面的就行了,back或者css1都可以了<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><div style="height:1000px"></div>
    <script>
        var timer, scrollHeight, viewHeight, step = 20, sTop = 0,isScrict=document.compatMode=='CSS1Compat';
        document.onclick = function () { clearInterval(timer); }
        function Move() {
            //设置滚动前获取当前的的滚动高度和sTop比较,如果小于sTop或者和sTop的差距大于step定义的,说明拖拽过滚动条了
            var nowScrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
            if (nowScrollTop < sTop || (nowScrollTop - top > step)) clearInterval(timer);
            sTop += step;
            document.documentElement.scrollTop = document.body.scrollTop = sTop;
            if (sTop + viewHeight > scrollHeight) {//滚动到底部
                clearInterval(timer);
                document.documentElement.scrollTop = document.body.scrollTop = 0//跳转到顶部
            }
        }
        window.onresize = function () {
            viewHeight = document[isScrict?'documentElement':'body'].clientHeight;
            scrollHeight = document[isScrict?'documentElement':'body'].scrollHeight;
        }
        window.onload = function () {
            window.onresize();
            timer = setInterval(Move, 100);
        }
    </script>
      

  5.   

    非常感谢,都符合我的要求了,不过我加了一段控制导航浮动的js之后,页面在滚动到最底部之后不会自动返回顶部了,应该是这两段js略有冲突吧?function tools(){
     var top=$(document).scrollTop();
     if(($.browser.msie==true)&&($.browser.version==6.0)){
      if(top>168)$("#box1_1").css({position:"absolute",top:top-168});
     }else{
      if(top>168)$("#box1_1").css({position:"fixed",top:0});
     }
     if(top<=168)$("#box1_1").css({position:"static",top:0});
    }
    $(function(){
     window.onscroll=tools;
     window.onresize=tools;
    });
    </script>
      

  6.   

    不要覆盖原来的onresize,改成这样,因为在onload中调用 window.onscroll获取视窗和滚动高作为是否滚动到页脚的代码//window.onscroll=tools;
    //window.onresize=tools;
    //===>
    $(window).bind({scroll:tools,resize:tools})