Tôi hy vọng tìm được cách lấy vị trí của cửa sổ có thể xem hiện tại (so với tổng chiều rộng / chiều cao của trang) để tôi có thể sử dụng nó để buộc cuộn từ phần này sang phần khác. Tuy nhiên, dường như có rất nhiều tùy chọn khi đoán đối tượng nào giữ X / Y thực sự cho trình duyệt của bạn.
Tôi cần phải đảm bảo IE 6+, FF 2+ và Chrome / Safari nào trong số này?
window.innerWidth
window.innerHeight
window.pageXOffset
window.pageYOffset
document.documentElement.clientWidth
document.documentElement.clientHeight
document.documentElement.scrollLeft
document.documentElement.scrollTop
document.body.clientWidth
document.body.clientHeight
document.body.scrollLeft
document.body.scrollTop
Và có ai khác không? Khi tôi biết cửa sổ ở đâu, tôi có thể đặt chuỗi sự kiện sẽ từ từ gọi window.scrollBy(x,y);cho đến khi đạt đến điểm mong muốn.