<script>
function getScoll() {
return {
left: window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
top: window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
}
}
window.onscroll = function () {
console.log('页面纵向滚出去的距离为:' + getScoll().top + 'px')
}
</script>