0

So I've got the following code:

window.onload = function () {

function getScrollTop() {
    if (typeof window.pageYOffset !== 'undefined') {
        // Most browsers
        return window.pageYOffset;
    }

    var d = document.documentElement;
    if (d.clientHeight) {
        // IE in standards mode
        return d.scrollTop;
    }

    // IE in quirks mode
    return document.body.scrollTop;
}

window.onscroll = function () {
    var reviewbasket = document.getElementById('reviewbasket'),
    scroll = getScrollTop();

    if (scroll > 950) {
        $("#global").stop;
    }
    else {
        reviewbasket.style.top = (scroll + 0) + "px";
    }
};

};

Currently the scroll ends at 950 px however I wish for the div to scroll right up until the max height of either the content area (#content) or the page is reached. I also don't want the div to overlap the footer. The main problem I face is that this page is viewed in two different states: Logged in and Logged out, Logged out comes with an extra content area which pushes the basket down further and stops me being able to set a fixed height for the scroll to end.

Any tips or direction is welcome!

Thanks, Dan

4

1 回答 1

0

创建一个变量来保存内容 div 的高度。然后,当页面改变状态(登录 => 注销)时,调用一个函数来更新高度变量。

var maxScroll = $("#content").height();

function resetMaxScroll() {
    maxScroll = $("#content").height();
}

...

if (scroll > maxScroll) {
    $("#global").stop;
}
于 2013-04-16T13:48:32.760 回答