Head compatibility solution for JavaScript pages being rolled out

Time:2020-12-3

Code implementation:

function getScroll() {
    return {
        left: window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0,
        top: window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0
    };
}

When using:

getScroll().left

or

getScroll().top